What is the difference between flushright and raggedleft?
2 Answers
\begin{flushright}...\end{flushright} is the environment form of \raggedleft. They are the equivalent of \begin{center}...\end{center} and \centering, respectively. Here's an example using the two:
\documentclass[twocolumn]{article} \usepackage{lipsum} \listfiles\begin{document} \lipsum[1] \begin{flushright}\lipsum[2]\end{flushright} \lipsum[3] \newpage \lipsum[4] {\raggedleft\lipsum[5]\par} \lipsum[6] \end{document} In particular, note the extra space around flushright.
- Use of trivlist is a key difference, so {flushright} isn't really the environment form of \raggedleft. I just had a case where the implicit use of {flushright} messed things in a way that was hard to debug., Suppose your page output style includes a page header that uses \flushright or \flushleft in some way. If page 1 breaks as a result of new material that invoves another trivlist -- in my case a theorem environment from the standard amsart.cls -- the trivlist opening (Theorem 1.1) gets tacked onto the page 1 header, instead of staying with the trivlist text at the top of page 2!Silvio Levy– Silvio Levy2023-03-24 06:49:42 +00:00Commented Mar 24, 2023 at 6:49
- @SilvioLevy — something about that doesn't sound quite right to me; I wouldn't think it's possible for interaction between the paragraph builder and the page builder in the way that you describe. But it's been a long time since I looked into code of that sort, so I probably shouldn't comment really...Will Robertson– Will Robertson2023-03-26 08:52:33 +00:00Commented Mar 26, 2023 at 8:52
The environments internally are based on a list (exactly a »trivlist«) with fixed list parameters. That's why they cause the extra vertical space before and behind that Will mentioned. The amount of this space is determined by the length \topsep. Regarding the center environment this can be very annoying when used to center float objects.
- 13Which is why you should use
\centeringto centre floats rather than{center}. (Or, better, use something like floatrow to automatically centre them.)Will Robertson– Will Robertson2010-10-01 08:17:37 +00:00Commented Oct 1, 2010 at 8:17 - Yes, and I should have added that.Thorsten Donig– Thorsten Donig2010-10-01 08:23:04 +00:00Commented Oct 1, 2010 at 8:23