# An .eps image, whose caption is too separated from the image.

I am writing a thesis in a large .tex file in Vim. I have an .eps image, whose caption is too separated from the image.

I have extensively read similar posts, tried almost everything, but the problem still persists, because it only occurs with this particular image:

imagefilename.eps


I would appreciate very much if you could help me.

I have a very simple preamble.

The rest of the captions (from the rest of the .eps images) have the exact space that I need, except for this particular image. This way, I would not prefer to write commands in the preamble, due to this will modify all captions of the rest of the images. I would only like to reduce the space image-caption of this particular image.

I don’t know why the space caption-image for this particular image is bigger than the rest.

Here is the code that introduces the image:

\begin{center}
\begin{figure}
\begin{center}
\includegraphics[scale=0.150,angle=0]{imagefilename.eps}
\caption{\small\sf This text is the image caption for the image showed. Note that this text is too separated from the image above.}
\label{image}
\end{center}
\end{figure}
\end{center}


Here is the link to direct download of the image, in order to check previously if a possible solution works:

https://www.mediafire.com/?xtub719odxrvbsx

I also show a direct link of another .eps image:

https://www.mediafire.com/?225azt8wkhyblzh

Just try to maintain the last code, and replace the

imagefilename.eps


with

a.eps


And you will see that the caption for a.eps is closer to the figure (!!!)

My preamble is this:

\documentclass[12pt,a4paper,twoside,openany]{report}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\parindent 1 true cm
\usepackage[dvips]{graphicx}
\usepackage{eufrak}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{amsmath}
\usepackage{graphicx,epsfig}
\usepackage{multirow}
\usepackage{float}
\usepackage{color}
\usepackage[longnamesfirst,super]{natbib}
\setcitestyle{square}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter .\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection .\ #1}{}}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[CE,CO]{}
\renewcommand{\baselinestretch}{1.25}
\usepackage{enumerate}
\usepackage{courier}
\begin{document}


I would appreciate very much if someone could help me, making tests with the images provided above, using my preamble, and the code that introduces the image. (I am writing the thesis .tex file in Vim).

• the caption command should not have font commands (and definitely not font size change) that should be part of the document style (and would be unwanted in a list of figures) also the two letter font commands such as \sf have been deprecated since latex2e was introduced in 1993. The center environment outside the figure should be removed, and the center environment inside figure should be replaced by \centering otherwise you will get anomalous vertical space. Please always try to post complete small documents that show the problem not fragments as here – David Carlisle May 23 '14 at 22:43
• The report class inserts a fixed space above captions, so most likely there is white space actually in your image which you can adjust with trim option to \includegraphics, or simply using a blank line and \vspace{-2mm} after the image. – David Carlisle May 23 '14 at 23:04

Your preamble has several sins; but that's not the problem. If you type

\fbox{\includegraphics[scale=0.150,angle=0]{imagefilename.eps}}


TeX will add a frame and you'll realize that the figure has wide blank space around the main part:

How can you do? Add the trim option; I tried

\includegraphics[scale=0.150,trim=300 450 300 500,clip]{imagefilename.eps}


and the result is

(still with \fbox to show better the image, remove it when you're satisfied). The four parameters are the length (in PostScript points) to trim from the four sides in the order “left bottom right top”.

\documentclass[12pt,a4paper,twoside,openany]{report}

%%% language part
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[spanish]{babel}

%%% page geometry
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}

%%% fonts
\usepackage{mathptmx} % times is obsolete
\usepackage{courier}
\usepackage{eufrak}

%%% misc packages
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{float}
\usepackage{color}
\usepackage{fancyhdr}
\usepackage{enumerate}
\usepackage{caption}

%%% bibliography package
\usepackage[longnamesfirst,super]{natbib}

%%% settings
\setcitestyle{square}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter .\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection .\ #1}{}}
\fancyhf{} % clear all fields
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\baselinestretch}{1.25}

\captionsetup{font={small,sf}}

\setlength{\parindent}{1cm} %%% WHY?

\begin{document}

\begin{figure}
\centering

\fbox{\includegraphics[scale=0.150,trim=300 450 300 500,clip]{imagefilename.eps}}

\caption{This text is the image caption for the image showed. Note that this text
is too separated from the image above.}
\label{image}

\end{figure}

\end{document}


The packages times and epsfig are obsolete; the second one should never be used, to substitute the first one load mathptmx or, better

\usepackage{newtxtext,newtxmath}


The option dvips should never be passed to graphicx.

For changing the font of captions, use the caption package. Don't put figure inside a center environment and don't use center inside, but the simple declaration \centering.

• Surely, the \fbox option clearly demonstrates that the image has a wide blank space !! (It is a characteristic of the image itself). Very smart solution the trim option, due to it allows me to eliminate this extra bottom space. Definitively, I have really understood why not to use center:it adds more virtual space;better\centering. I really appreciate it the polished version of the preamble, although I have some questions regarding some of the packages you suggested. I will try to investigate more about them a bit later, due to I have to continue writing. Thank you very much !! – DavidC. May 26 '14 at 21:32
• I have found a new problem related to a table: Here I show the post if you would like to check it out: – DavidC. May 26 '14 at 21:33
• @egregThe \captionsetup{font={small,sf}} seem not to be working... See: tex.stackexchange.com/questions/186250/… – DavidC. Jun 23 '14 at 19:47

I first converted the images to .pdf format and cropped them with an external tool (epspdf). Then I only had to choose a suitable scale factor. Here is the code, with only the necessary packages, and a font I like better than Times:

\documentclass[12pt,a4paper,twoside,openany]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\parindent 1 true cm
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage{graphicx}

\renewcommand{\baselinestretch}{1.25}

\begin{document}

\begin{figure}[!htbp]
\centering\includegraphics[scale=0.5]{a}
\caption{A First Image}\label{img1}
\end{figure}

\begin{figure}[!htbp]
\centering\includegraphics[scale=0.25]{imgfilenamecropped}
\caption{A Well-known Molecule}\label{img2}
\end{figure}

\end{document}


P.S. — As the job is already done, it's useless to redo it, but I don't know whether it is possible to attach the .pdf images.