Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

center, centering and begin{center}

19 views
Skip to first unread message

jimmij

unread,
Jan 20, 2005, 11:44:26 AM1/20/05
to
Hello,
Can someone shortly explain me a difference between:


% 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=\textwidth]{figure.eps}
\caption{foo}
\label{fig:lab}
\end{center}
\end{figure}
% 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[htbp]
\center
\includegraphics[width=\textwidth]{figure.eps}
\caption{foo}
\label{fig:lab}
\end{figure}
% 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[htbp]
\centering
\includegraphics[width=\textwidth]{figure.eps}
\caption{foo}
\label{fig:lab}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Which method is the best and why?

thanks,
jimmij

--
I come from the Land Of Imagination

Lars Madsen

unread,
Jan 20, 2005, 12:09:37 PM1/20/05
to

> % 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%
> \begin{figure}[htbp]
> \centering
> \includegraphics[width=\textwidth]{figure.eps}
> \caption{foo}
> \label{fig:lab}
> \end{figure}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> Which method is the best and why?
>
> thanks,
> jimmij
>

the first two examples are more or less equivalent
(\begin{center}...\end{center} is the same as \center ... \endcenter)

the last is prefered because

figure adds vertical space before and after the figure
center add (same)

so with the combination of figure and center you get a doublespacing
before and after whereas the combination of figure and \centering only
gives you the spacing from figure.


--
/daleif (remove RTFSIGNATURE for email)

Vilar Camara Neto

unread,
Jan 20, 2005, 12:27:04 PM1/20/05
to

\centering just tells LaTeX to center the current and following
paragraphs. \begin{center}...\end{center} also put an additional
vertical space before and after the centered material.

\center should not be used, because it's the same as \begin{center} --
unless you close the "environment" with \endcenter, which is the same as
\end{center}. (In general, \begin{xxx} = \xxx and \end{xxx} = \endxxx.)

> Which method is the best and why?

IMHO, \centering is the best inside the figure environment, because the
vertical spacing is already controlled by the floating placement mechanism.

--
Best regards,

Vilar Camara Neto

David Carlisle

unread,
Jan 20, 2005, 12:42:22 PM1/20/05
to
jimmij <jim...@jimmij.jimmij> writes:

2 isn't really supported LaTeX syntax. There is no documented \center
command: it only works because of a side effect of the implementation of
the center environment.

The difference between the center environment and the \centering
declaration is that the center environment adds some "display spacing"
vertical space above and below the centred text which you may or may not
want, but also, being an environment it sets up a local group.

\label associates the current reference dounter with the specified
string but that reference counter is set _locally_ by \caption (or most
other commands that setthis, such as \section) so if you put \label
outside this group teh current reference counter has reverted to its
value before the group. You would see the same effect with

\begin{figure}[htbp]


\includegraphics[width=\textwidth]{figure.eps}
{ \caption{foo} }
\label{fig:lab}
\end{figure}

generally speaking it's best to put the \label inside the caption
argument. Or failing that put it immediately after the \caption
it must at least be in the same group as the caption.

David

0 new messages