[Tex/LaTex] How to trim the white space before figure caption

graphicsieeetran

I'm using

\documentclass[journal,transmag]{IEEEtran}
\usepackage[pdftex]{graphicx}
\begin{document}
%
\setlength{\textfloatsep}{0pt}
\begin{figure*}[!t]
\centering
\scalebox{.9}{\includegraphics[width=\linewidth]{fig}}
\caption{result}
\end{figure*}
%
\end{document}    

and I'm inserting a ".pdf" figure. The problem is that I have a big white space after the figure and before the caption. In generating the ".pdf" file I've tried to minimize the white space as much as I could but when uploading in Latex there appears to be a bis white empty space. Can I trim this in Latex?

Thank you.

Best Answer

Trimming of PDF images

The program pdfcrop calls ghostscript to calculate the visible area of the image and writes a PDF file with the new bounding box without the white space margins:

pdfcrop fig.pdf

This writes fig-crop.pdf. Also a different output file name can be specified, see pdfcrop's options.

Then the cropped image is inserted in LaTeX:

\includegraphics{fig-crop}

Alternatively options trim or viewport of \includegraphics can be used to reduce the margins. But the margins have to be measured for specifying the right arguments for trim or viewport, see LaTeX's graphics guide.

Change of default spacing above figure captions

The class IEEEtran has hooks: for setting the space between the figure and its caption and a table caption and its table

\def\@IEEEfigurecaptionsepspace{\vskip\abovecaptionskip\relax}%
\def\@IEEEtablecaptionsepspace{\vskip\abovecaptionskip\relax}%

They can be redefined to reduce the space:

\makeatletter
\renewcommand*{\@IEEEfigurecaptionsepspace}{%
  \vskip.5\abovecaptionskip\relax
}%
\makeatother

Or

\makeatletter
\renewcommand*{\@IEEEfigurecaptionspace}{}
\makeatother

But beware, the journal might want to have the original space.

Related Question