Tag Archives: minipage

Using footnote in tables

Have you ever tried to add a footnote to a table inside the tabular environment? Even though the index is printed, the search for the actual footnote will be in vain.

One way to overcome this issue is by using longtable. The package handles footnotes really well. But it may be an overkill if your table is small.
Also, I read the tabularx package also handles footnotes correctly, I haven’t tested it though.

Another, more appropriate solution would be using the minipage environment. Here is an example:

\begin{minipage}{6cm}
	\begin{tabular}{|l|c|c|}
		\hline
		A & 1 & 2 \footnote{This is a footnote.} \\
		\hline
		B & 2 & 1 \\
		\hline
		C & 3 & 3 \\
		\hline
	\end{tabular}
\end{minipage}

Minipage table footnote example

Minipage table footnote example.

Obviously, the footnote is placed right below the table, which may or may not be what you want. In addition, since minipage is not a floating environment, adding a caption inside the minipage environment gives the following error message: “LaTeX Error: \caption outside float”. If you want to send the footnote to the bottom of the page and replace the index with a number rather than a alphabetic character, you may use the minipage*-environment of the footnote package:

\documentclass[12pt]{article}
\usepackage{footnote}
\begin{document}
\begin{minipage*}{6cm}
	\begin{tabular}{|l|c|c|}
		\hline
		A & 1 & 2 \footnote{This is a footnote.} \\
		\hline
		B & 2 & 1 \\
		\hline
		C & 3 & 3 \\
		\hline
	\end{tabular}
\end{minipage*}

The code above places the footnote where and how we want it, but the issue with the caption remains.

What finally saved my day was having a look at the documentation of the footnote package. It provides the savenotes environment, which collects all footnotes inside the tabular where they get stuck and “releases” them at the end. Here is an example:

\documentclass[12pt]{article}
\usepackage{footnote}
\begin{document}
\begin{savenotes}
	\begin{table}[ht]
		\centering
		\begin{tabular}{|l|c|c|}
			\hline
			A & 1 & 2 \footnote{This is the first footnote.} \\
			\hline
			B & 2 & 1 \\
			\hline
			C & 3\footnote{This is the second footnote.} & 3 \\
			\hline
		\end{tabular}
		\caption{A table caption.}
		\end{table}%
	\end{savenotes}
\end{document}

Footnote in table example, result of code.

Footnote in a table.

 

Update: conflict with xcolor package

There is a conflict between the xcolor and the footnote packages. You can fix it by first loading the xcolor package.

The error you will see is either:

Missing } inserted.

or

Extra }, or forgotten \endgroup


Creating two columns in article, report or book

Three different styles have to be distinguished when creating multiple columns in a Latex document. Either we want the whole document to have two columns, single pages or only part of a page. In order to do so, three different Latex commands are used…

Whole document (using article to write a paper):

The only thing you need to do is changing the first command of your Latex-file.

\documentclass[11pt,twocolumn]{article}

It will automatically create two columns in the entire document.

Note: if you are writing a paper, IEEE provides useful templates which can be used and adapted to your needs. You can download them from their “Author Digital Tool Box“.

Single pages:

The command \twocolumn starts a new page having two columns. Accordingly, \onecolumn starts a new page with a single column assuming you are in a two column environment as described above. Both commans do not take any arguments.

The is a way to define the distance between the two columns, use

\setlength{\columnsep}{distance}

If you need a line to separate the columns, the following command will do the job:

\setlength{\columnseprule}{thickness}

Part of a page:

I have posted another article on that, just have a look there. \minipage can also be used for text, not only for figures and tables.


Placing figures/tables side-by-side (\minipage)

Including images in a report is very common in Latex. Structuring your work nicely is probably the most obvious reason why you want to put two figures/tables side-by-side. Another reason might be to save space, wherever a smaller size of an image is sufficient. The following code can be used to place two figures side-by-side by creating a minipage…

\begin{figure}[ht]
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{filename1}
\caption{default}
\label{fig:figure1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{filename2}
\caption{default}
\label{fig:figure2}
\end{minipage}
\end{figure}

Note, for certain figure manipulations such as width, loading the graphicx package is required:

\usepackage{graphicx}

The same “local column” – effect can be achieved for tables. The following code shows you how:

\begin{table}[ht]
\begin{minipage}[b]{0.5\linewidth}\centering
\begin{tabular}{|c|c|c|}
\hline
1&1&1\\
\hline
2&2&2\\
\hline
\end{tabular}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{tabular}{|c|c|c|}
\hline
1&1&1\\
\hline
2&2&2\\
\hline
\end{tabular}
\end{minipage}
\end{table}

You can also have more than two column simply by adding another \minipage in between the table-command and reduce the width of each \minipage (0.33\linewidth in addition to the \hspace). LaTex will automaticaly place objects onto the next line, if space is not sufficient.

Remark: Using the subfigure-package is another way to place figures or tables side-by-side. You might want to have a look at this post on subfigures.


Follow

Get every new post delivered to your Inbox.

Join 316 other followers