3

I am writing a paper for a journal and have to use the bmcart class of the BioMed Central template found here (direct link to ZIP file). I am using it with two columns:

\documentclass[twocolumn]{bmcart}

The bmcart class encloses every figure and its caption in a box. When I enable graphics in the template file:

\usepackage{graphicx}
%\def\includegraphic{}
%\def\includegraphics{}

and insert a plot without scaling:

\begin{figure}[h!]
  \includegraphics{myplot}
  \caption{\csentence{Sample figure title.}
      Figure legend text.}
      \end{figure}

then the plot overflows the box to the right. The width of my plot is 235 pt, the width I got using \showthe\columnwidth in a figure environment.

My question is: what is the optimal width for plots that I want to include so that when I do \includegraphics{myplot} there is no scaling and the plot fits perfectly inside the box drawn around it?

I would be really grateful if you could point out how to determine the optimal width in this case, but also in general, if possible.

Edit: thanks to @Fran for pointing out this question about the difference between \hsize, \columnwidth, \linewidth and other dimensions.

  • for me it is not clear what you want but can you try \includegraphics[width=\hsize]{myplot}? – touhami Apr 10 '15 at 12:36
  • I would try \includegraphics[width=\columnwidth]{myplot}. – Mico Apr 10 '15 at 12:39
  • @Mico, in the case of bmcart, \columnwidth overflows the box boundaries to the right. I wrote that in my post but made a typo so it wasn't clear, now I fixed it. – nedim Apr 10 '15 at 13:17
  • @touhami, my goal was not to scale the plot using, i.e., the width parameter. However, your comment has lead me to a solution. If I make my plots as wide as \hsize then they fit perfectly without scaling! Thank you, please write this as an answer and I will gladly accept it. – nedim Apr 10 '15 at 13:19
  • @nedim there is no need to be answer. You're welcome. – touhami Apr 10 '15 at 13:48
3

In this case, \hsize returned the optimal width of the figure. \showthe\hsize returned 222.5 pt. When I made a 222.5 pt plot and included it in the paper using \includegraphics{myplot}, it fit perfectly without resizing.

In most cases though, \hsize should be avoided. I thank @egreg for his comment that clarifies why.

I thank @touhami for his comment that lead me to the solution.

  • I think that \linewidth is safer in general (see this famous question). BTW, why change the original image size instead of using [width=\linewidth]? You can lost some image resolution in the original source and overall ...It's a lot of work! – Fran Apr 10 '15 at 17:43
  • @Fran, thanks for the link, I added it to my question. I changed the image size because I generate the images from a script and width is a parameter so it's not a lot of work. The reason I avoid scaling is that in that case all font sizes in the image correspond 1:1 to the rest of the document, so if the document is using a specific font in a certain size, I can make sure that the included image has exactly the same settings. It adds to the visual appeal. – nedim Apr 11 '15 at 19:18
  • Avoid using \hsize. – egreg Apr 11 '15 at 23:21
  • @egreg, what is the reason for avoiding \hsize? I am not very experienced with LaTeX. – nedim Apr 12 '15 at 11:32
  • @nedim Because \hsize is an internal parameter and you're not guaranteed that its current value is the line width that will be used for typesetting the paragraph. On the other hand, in lists you can rely on \linewidth, while outside of lists \columnwidth is the parameter to be used. – egreg Apr 12 '15 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.