When using default LaTeX styles, you get a rather small text width. This is for a very good reason: readability. However, when you want to add an image, figure or table, this width can be a bit limiting. If you naively add an image (or table) that is wider than the text width, the image will typically align on the left margin and extend into the right margin, which is not that pretty. Moreover, because you're not using the left margin, it limits the maximum width you can use.
I found this nifty LaTeX recipe for overwide graphics, which I'd like to rehash.
The trick is to put the image (or something else) in a \makebox command:
To see it in action, I made a small but functional illustration with a fake image (using the \rule command):

The code to produce this:
\documentclass[12pt]{article} % Some float settings to get all the figures at the top of the page \setcounter{topnumber}{4} \setcounter{totalnumber}{4} % Make the captions larger so we can read them in the screenshot. \usepackage[Large]{caption} \begin{document} % An image that is small enough. \begin{figure} \centering \rule{5cm}{1em} \caption{Faking a small image with the rule command.} \end{figure} % An overwide image. \begin{figure} \centering \rule{17cm}{1em} \caption{What about a wide image?} \end{figure} % Using the makebox trick to align it nicely. \begin{figure} \makebox[\textwidth][c]{ \rule{17cm}{1em} } \caption{This looks better, doesn't it?} \end{figure} % The same makebox trick with right alignment. \begin{figure} \makebox[\textwidth][r]{ \rule{17cm}{1em} } \caption{We can even align it to the right.} \end{figure} % A bit of nonsense text to visualize the normal margins. \section{Iprem Losum} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sed mattis lorem. Mauris consectetur, diam a condimentum fermentum, diam sem tincidunt libero, eu venenatis nulla turpis congue urna. Quisque sagittis iaculis turpis, id adipiscing sapien lobortis eu. Curabitur elementum, turpis et vehicula iaculis, augue sem egestas odio, vel ornare dui erat nec sem. Cras massa tellus, commodo nec tincidunt a, bibendum in ipsum. Donec nisi dolor, ultrices eu aliquet non, placerat ut orci. Nulla neque augue, vehicula et tempor eget, mattis vitae augue. Maecenas eu felis mi, non adipiscing libero. \end{document}
Thanks!
It was the only solution that worked for me, I tried complicated ones before that, like changing the margins temporarily etc.
Thank you very much!
Thanks!
It was the only solution that worked for me, I tried complicated ones before that, like changing the margins temporarily etc.
Thank you very much!
Read the "epslatex" guide
This is a nice and simple trick. But before going further, I suggest spending a few days reading the wonderful guide that is "epslatex.pdf".
It can be found in standard CTAN mirrors: http://ctan.org/tex-archive/info/epslatex/
The guide covers a lot of things, some of which I'm sure I'll never use. But if I ever actually need to use them, I'm confident this guide will be able to point me in the right direction.
As for this post, I just have one suggestion: instead of using \textwidth, I think it's good practice to use \linewidth. The latter is basically \textwidth in the *current* environment, that is, if you are inside some other environment that modifies the text width, the figure will use this new width instead of the global \textwidth which, I believe, is fixed.
great tip!
I linked to this post from another one of yours on working with bash, and it happened to answer an exact problem I've been having with typesetting my dissertation! Obviously when the secretaries with the rulers come out for the final verdict, I'll have to resize the figures, but for now this is just what I'm looking for. Thanks!
Post new comment