With those wide margins of LaTeX, it sometimes happens that you have a figure or table that is too wide, and just sticks out to the right. Chances are that you want it centered, sticking out equally to the right and to the left, but tough luck: the standard center
environment still aligns it with the left margin, and so does the \centering
command.
I was about to write a package to provide an environment that centers its content on the page instead of inside the text. This is not too difficult, but preventing the overfull \hbox
errors is tricky (they are so bad that even \hbadness=10000
has no effect). But then I stumbled into a standard LaTeX command that does exactly what I want.
So here's how to center your figure whilst ignoring the text margins:
\centerline{\includegraphics{...}}
It also works inside float environments such as figure
. That was easy!
18 comments:
This has nothing to do with your current post here, but i had to stop by and praise you. I've been searching for days for a way to fix my sid-by-side error messaging in my visual basic 2008 programs when i execute them on another machine and no one was able to give me a straight answer on how to resolve the issue. However your post titled "Visual C++/Studio: Application configuration incorrect?" on another site made my day... and all is as it should be in the world again... thanks for sharing that information on the web.
Wow, this is great!! thank you so much!
Perfect! Exactly the thing I needed. Thanks.
thanks for the help Typethinker. It's great having people like you who have others' interest in their minds.
Perfect!
Super cool! Thank you so much!
The same, thank you man. It took me a long while to find your solution, but this is it.
Great, you made my day!
You saved me! searching the answer for 2days!!!
dude! awesome! This works like a charm. I have two images side by side in an array and it was ticking to the right even with the use of \center. This solved it. Thanks for sharing!
thx, exactly what i was looking for :)
You have made a tired scientist much happier. Thank you!
Thanks a lot!You solved one of my problems! that works perfectly for one figure but what if I have more than one figure??where should I place the command \centerline{}?
Here is my piece of code:
\begin{figure}[ht!]
\begin{center}
%
\subfigure[LYSO total spectrum, 80 ns]{%
\label{fig:LYSOtotal80.png}
\includegraphics[scale=0.35]{LYSOtotal80.png}
}%
\subfigure[LYSO total spectrum, 90 ns]{%
\label{fig:LYSOtotal90.png}
\includegraphics[scale=0.35]{LYSOtotal90.png}
}
%
\end{center}
\caption{Total spectra for integration time equal to 80 and 90 ns, it can be noticed how both spectra are the same although the one for 90 ns has a bit more number of counts since the integration time is longer. }%
\label{fig:fc}
\end{figure}
I've tried to put \centerline{} in each figure but then both figures overlap... any idea of how to do this?
Thanks!
No idea, sorry.
Thanks a lot for the centerline!
Exactly what I was lookingfor
This was super helpful. Thank you!
Thank you! ...but...in which package is it?
It's included in LaTeX itself, no need to add any packages.
Post a Comment