LaTeX forum ⇒ Theses, Books, Title pagesCentering oversize image in text column Topic is solved

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Serpenthelm
Posts: 7
Joined: Mon Jun 04, 2012 3:50 pm

Centering oversize image in text column

Postby Serpenthelm » Tue Sep 08, 2015 4:01 pm

I'm using the masters-doctoral-thesis template and I'm trying to center a slightly oversize png image. I'm compiling with pdflatex.

The image is too big to fit the column, but is there a way to make it centered respective to the column text, instead of it simply go out to the right?

Image

This is the code
  1. \chapter{The power grid}
  2. \label{Chapter2}
  3. \lhead{Chapter 2. \emph{The power grid}}
  4.  
  5. \begin{figure}[]
  6. \centering
  7. \includegraphics[scale=1]{Images/misc/PJM_Daily_Demand.png}
  8. \caption{Average daily and hourly demand in the transmission system operated by...}
  9. \label{fig:daily_demand}
  10. \end{figure}

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1974
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Tue Sep 08, 2015 7:55 pm

You have two options:

  • scale the image so it fits
  • put the picture in a box that fits

  1. \documentclass{article}
  2. \usepackage{graphicx}
  3. \usepackage{showframe}% show page dimensions
  4. \begin{document}
  5. \begin{figure}
  6. \includegraphics[width=\linewidth]{Figure_centering.png}
  7. \end{figure}
  8. \begin{figure}
  9. \makebox[\linewidth][c]{\includegraphics{Figure_centering.png}}
  10. \end{figure}
  11. \end{document}


The line \makebox[\linewidth][c]{...} puts its contents in a box of width \linewidth and centers its contents (c). The second optional argument [c] isn't necessary as this is the default alignment. \makebox[\linewidth]{...} would suffice.

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

Serpenthelm
Posts: 7
Joined: Mon Jun 04, 2012 3:50 pm

Postby Serpenthelm » Wed Sep 09, 2015 3:48 pm

Putting the picture in a box did the trick.
The box can grow much wider than the text column, and that is what I wanted.
However, \includegraphics[width=\linewidth] did not help.

Thank you.

User avatar
cgnieder
Site Moderator
Posts: 1974
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Thu Sep 10, 2015 4:36 pm

Serpenthelm wrote:However, \includegraphics[width=\linewidth] did not help.


“Did not help” is a rather vague description. I know that this proposal doesn't center the overwide figure with respect to the text body. Instead it scales the figure down so it fits exactly. While this might be not the solution you looked for it still might come in handy with another figure some day :)

(Besides: personally I prefer figures not to be wider than the text but that is a matter of taste I guess.)

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim


Return to “Theses, Books, Title pages”

Who is online

Users browsing this forum: No registered users and 2 guests