Possible Duplicate:
Why the end-of-line % in macro definitions?
I am not sure what is happening with this MWE.
First the problem: You can clearly see the whitespace between the label and the text of the caption.

The MWE given below produces this behaviour.
\documentclass{report}
%--- SECTION1-----
%https://tex.stackexchange.com/questions/69662/how-to-globally-change-the-spacing-around-equations
\expandafter\def\expandafter\normalsize\expandafter{%
\normalsize
\setlength{\abovedisplayskip}{5pt plus 2pt minus 3pt}
\setlength{\abovedisplayshortskip}{3pt plus 2pt}
\setlength{\belowdisplayskip}{5pt plus 2pt minus 3pt}
\setlength{\belowdisplayshortskip}{3pt plus 2pt}
}
%-----SECTION2-----
\usepackage{setspace}
%-----SECTION3-----
\usepackage{caption}
\captionsetup{%
textfont={singlespacing},
}
%------------------
\begin{document}
\begin{figure}
\centering
\rule{3cm}{2cm}
\caption{Application of ICA for two sources with Gaussian distribution}
\label{fig:icaDistributions}
\end{figure}
\end{document}
The preamble is separated in three sections. The code in section-1 for setting various lengths is from how-to-globally-change-the-spacing-around-equations. As far as I understand it, the lengths will be defined each time \normalsize is defined/changed. Since we are setting these lengths to constants, the change in fontsize won't affect these lengths. Since various people have recommended this method, I am assuming this is a good practice.
Here are some observations:
- If any one of the sections are commented out, then the white space disappears.
- If section-1 is modified by adding comment mark
%at the end of these lines then the whitespace disappears. - In fact, each line with
setlengthis adding a whitespace after the label incaption.
\expandafter\def\expandafter\normalsize\expandafter{% \normalsize \setlength{\abovedisplayskip}{5pt plus 2pt minus 3pt}% \setlength{\abovedisplayshortskip}{3pt plus 2pt}% \setlength{\belowdisplayskip}{5pt plus 2pt minus 3pt}% \setlength{\belowdisplayshortskip}{3pt plus 2pt}% }
The questions are:
- Is the method of setting lengths correct?
- Why does the spurious space disappear when
setspacepackage is not used? - Why does the spurious space disappear when
singlespacingoption from packagecaptionis not used? - Why does the spurious whitespace disappear when
%is added at the end of thesetlengthcommand lines?
I would like to know what is happening here and what is the correct way of handling this problem.
setspaceis not used. – devendra Jan 01 '13 at 09:04singlespacingis used and thesetspacepackage is loaded,\setstretch{1}will be used prior typesetting the caption, and this will call\normalsizein TeX`s horizontal mode. – Jan 01 '13 at 09:23setspacepackage is not loaded the caption optiontextfont=singlespacingsimply does nothing. (See caption3.sty how the font settingsinglespacingis defined.) – Jan 01 '13 at 09:29latexgive me errors whenever I have left an unintended whitespace? (something like strict compilation rules) – devendra Jan 01 '13 at 09:33