Place Tables and Figures Precisely in LaTeX

I use to write my papers in LaTeX. One thing which I found always annoying about LaTeX is the issue with placing tables and figures inside a document. Usually you can place your tables or figures inside environments, like the table environment or the figure environment:

\begin{table}[htbp]
\begin{tabular}{|p{3cm}|p{3cm}|p{8.5cm}|}
\hline \textbf{R1,C1} & \textbf{R1,C2} & \textbf{R1,C3} \\ 
\hline R2,C1 & R2,C2 & R2,C3 \\
\hline R3,C1 & R3,C2 & R3,C3 \\
\hline R4,C1 & R4,C2 & R4,C3 \\
\hline 
\end{tabular} 
\caption{This is the table caption text}
\label{tbl:mytable}
\end{table}
 
\begin{figure}[htbp]
\includegraphics{mypicture.eps}
\caption{This is the image caption text}
\label{fig:mypicture}
\end{figure}

If you want to be “master of tables”, all you have to do, is get rid of the table environment and put your table inside a center environment as shown below:

\begin{center}
\begin{tabular}{|p{3cm}|p{3cm}|p{8.5cm}|}
\hline \textbf{R1,C1} & \textbf{R1,C2} & \textbf{R1,C3} \\ 
\hline R2,C1 & R2,C2 & R2,C3 \\
\hline R3,C1 & R3,C2 & R3,C3 \\
\hline R4,C1 & R4,C2 & R4,C3 \\
\hline 
\end{tabular} 
\caption{This is the table caption text}
\label{tbl:mytable}
\end{center}
 
\begin{center}
\includegraphics{mypicture.eps}
\caption{This is the image caption text}
\label{fig:mypicture}
\end{center}

The problem is, that the above code does not create a proper caption text. In order to get the same caption text functionality as before, you’ll have to include the “caption” package in your preamble:

/usepackage{captionof}

As a last step, modify your caption command:

\begin{center}
\begin{tabular}{|p{3cm}|p{3cm}|p{8.5cm}|}
\hline \textbf{R1,C1} & \textbf{R1,C2} & \textbf{R1,C3} \\ 
\hline R2,C1 & R2,C2 & R2,C3 \\
\hline R3,C1 & R3,C2 & R3,C3 \\
\hline R4,C1 & R4,C2 & R4,C3 \\
\hline 
\end{tabular} 
\captionof{table}{This is the table caption text}
\label{tbl:mytable}
\end{center}
 
\begin{center}
\includegraphics{mypicture.eps}
\caption{figure}{This is the image caption text}
\label{fig:mypicture}
\end{center}

After that, everything should be fine and your tables and figures should appear, where you wanted them to be.

Have Fun! 🙂

2 thoughts on “Place Tables and Figures Precisely in LaTeX

  1. Stefan

    For a small paper, such manual placement can be ok. But for a book with hundreds of pages and figures or tables it could be hard – change somethin at the beginning and dozens of figures or tables might need to be replaced since page breaks have changed. With large documents, LaTeX’s automatic figure and table placement is great, together with the cross-referencing. You could adjust the placement parameter, either by writing [!htbp] or by adjusting placement variables.

    Reply
  2. andre

    Hi Stefan, thanks for your reply and sorry for the late approvement of your post. I totally agree with you and also recommend making use of LaTeX automatic placement. In my case, I had to to write a piece of text containing some tables between the paragraphs. the code above was till now the only way to make sure a table gets exactly placed where I needs to be. Unfortunately I’ve found no better way to achieve this yet.
    My observation was, that even with [!htbp] set, LaTeX sometimes overrides these settings in terms of good layout practices. Best regards, André

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*