I am adding figures to a work and most of the figures are too wide and are thus not centered but are shifted to the right. I searched here and found a solution, that would consist in adding the \centerline{}
command into the figure environment. This work fine for figures added with the command \includegraphics{}
, like in this example:
\begin{figure}[h!]
\begin{center}
\centerline{\includegraphics{SOIR_optics}}
\end{center} % is this really useful?
\end{figure}
But when I try to add a tikzpicture
instead, this solution does not work (see example)
\begin{figure}[h!]
\begin{center}
\centerline{\begin{tikzpicture}
some code
\end{tikzpicture}}
\end{center}
\end{figure}
My question is : are there alternatives to this \centerline{}
command?
Thanks!
Best Answer
The
\centerline
command should never be used in a LaTeX document (unless you know precisely what you're doing, and probably only in the preamble for some definition). Useand
<whatever>
(a graphic, a TikZ picture or anything) will be centered.