Banner

Donate

You find LaTeX Community useful? Please donate! Learn why!

Amount:

Partner Sites

goLaTeX
TeXblog
TeXnicCenter

Who is online

In total there are 16 users online :: 2 registered, 0 hidden and 14 guests (based on users active over the past 5 minutes)
Most users ever online was 108 on Tue Jun 08, 2010 3:33 pm

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 14 guests

Can't stom centering

LaTeX specific issues not fitting into one of the other forums of this category.

Can't stom centering

Postby avp3000 on Tue Jun 03, 2008 2:09 pm

Hi all,

I noticed that, wenn I'm doing a presentation and put \centering on a slide, after that the text on the other slides is also centered, although I had enclosed the \centering command with {}. For example:

%Slide 1
{\centering Here is the text I want to be centered.}

%Slide 2
And here is the text I don't want to be centered, but it still is.

Why is that?

Thank you very much,
Alexander
avp3000
 
Posts: 49
Joined: Thu Nov 15, 2007 3:22 pm

Re: Can't stop centering

Postby Stefan_K on Tue Jun 03, 2008 2:37 pm

Hi Alexander,

try a paragraph break by an empty line or \par (or break the line by \\) to end \centering:
Code: Select all
{\centering Here is the text I want to be centered.\\}

Stefan
LaTeX Community Moderator
TeXblog.net
Stefan_K
Site Moderator
 
Posts: 2687
Joined: Mon Mar 10, 2008 8:44 pm
Location: Hamburg, Germany

Re: Can't stom centering

Postby avp3000 on Tue Jun 03, 2008 2:42 pm

Hello Stephen,

I tried that but it didn't want to compile the file. However, this is not a big thing, as I just use \begin{center}. I was just wondering why the hell it does that. Thank you for your advice.
avp3000
 
Posts: 49
Joined: Thu Nov 15, 2007 3:22 pm

Re: Can't stop centering

Postby Stefan_K on Tue Jun 03, 2008 3:26 pm

See here: \centering.
The scope of \centering needs to be limited, for instance by \par, else it affects the next lines too.

\begin{center} uses \centering internally too, but puts a list around it. One side effect of \begin{center} is that additional vertical space occures before and after the centered Text. If I don't want that I use {\centering text \\} or similar with \par.

Stefan
LaTeX Community Moderator
TeXblog.net
Stefan_K
Site Moderator
 
Posts: 2687
Joined: Mon Mar 10, 2008 8:44 pm
Location: Hamburg, Germany

Re: Can't stop centering

Postby localghost on Tue Jun 03, 2008 4:48 pm

Stefan_K wrote:[...] One side effect of \begin{center} is that additional vertical space occures before and after the centered Text. [...]

To avoid that, you could define a new environment (best placed in the preamble) that has no additional space above and below the centred text. Corresponding to its purpose I called the new environment centered.
Code: Select all
\newenvironment{centered}{%
  \begin{list}{}{%
    \topsep0pt
  }
  \centering
  \item[]
}
{\end{list}}

This is very similar to the internally defined center environment, which uses a trivlist environment with fixed parameters (like \topsep). Here we have a general list environment where we can give new parameters and so nearly eliminate the additional vertical spaces.


Best regards
Thorsten
¹ I'm sorry. My responses are limited. You must ask the right questions.
² Systems: openSUSE 11.3, TeX Live 2009, TeXworks 0.3 | Windows XP (SP3), MiKTeX 2.8, TeXworks 0.3
³ Learning TeX.
User avatar
localghost
Site Moderator
 
Posts: 4769
Joined: Fri Feb 02, 2007 11:06 am
Location: Braunschweig, Germany

Re: Can't stom centering

Postby avp3000 on Thu Jun 05, 2008 2:57 pm

Thank you both for the valuable information. It really helped.
avp3000
 
Posts: 49
Joined: Thu Nov 15, 2007 3:22 pm


Return to General

Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 14 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group