# No correct centering when a line break is used

I have a centering environment inside a figure. In this environment, I have a text written in a footnotesize style. If I make a line break (\\) in the text, then the text is not centered correctly anymore.

Can anyone tell me why the text is not centered correctly?

Screenshot:

Code:

\begin{figure}[H]
\noindent
\begin{centering}
\caption[HTTP-Polling]{HTTP-Polling}
\label{fig:polling}
\includegraphics[scale=0.5]{images/polling}
\par
\footnotesize Quelle: Heise Zeitschriftenverlag, 06. März 2012\\http://www.heise.de/developer/imgs/06/6/7/6/2/3/3/Polling-61cb54a128001c08.png
\end{centering}
\end{figure}

-
\centering is not an environment, but a command. Use \centering instead of \begin{centering} and remove \end{centering}. – egreg Mar 7 '13 at 15:25
Or you could use \begin{center} ... \end{center}, although this would introduce additional vertical spacing, which you can redefine by first setting, e.g., \topsep=0pt. – benwilfut Mar 7 '13 at 16:20

As mentioned in a comment there exists a directive called \centering that turns on "centering" from now on until the end of the current group. Technically speaking any command can turned into an environment (whether it makes sense or not) by simply using the command name without backslash as the envioronment name. The begin/end of the environment forms a group and the command is executed within its scope.
For directives that can make sense, e.g., \begin{itshape} ... \end{itshape} makes perfect sense and in some cases is preferable over {\itshape ...}. However, \begin{textbf}{...} ... \end{textbf} does not as the \textbf only operates on its argument, so the body of the environment doesn't serve any purpose.
Now coming back to your code: if a directive like \centering is used as an environment it is important to understand what happens at the end of this environment: nothing other than a group is closed ie the scope ends. That means what you have coded is equivalent of {\centering ...} without a final \par. But \centering operates only when the paragraph end is sensed (a \\ is really doing a par break internally) and by the time the final \par is seen (which is inside \end{figure} the \end{centering} was executed and changed the setting from centering back to normal justified settings. To make things like \centering work many environments such as the floats or the \parbox etc contain implicit \par commands at their end to ensure that the final paragraph is finished with its current setting prior to closing the current group. But here this comes too late.
Therefore to fix this you would need to include a \par or empty line before \end{centering} or just use \centering (which is the better approach here) with the scope being the whole figure environment.
Didn't you mean textbf instead of bftext? :) – Denis Bitouzé Dec 22 '15 at 14:55