3

I am trying to simply align one paragraph to the right. However, when I try to use flushright environment, additional vertical space is added above that environment:

\documentclass[final]{book}
\begin{document}

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus ut voluptatem at voluptatibus omnis ratione tenetur. A, voluptates. Enim beatae suscipit nesciunt sunt voluptatem, sit blanditiis nobis accusamus vitae nisi tempora odit eius molestias laborum obcaecati maiores optio placeat aut temporibus alias omnis porro minus ex! Illum dolores, explicabo assumenda?

\begin{flushright}
This text should be aligned to right side with no vertical space above it.
\end{flushright}

Some regular text which should not be affected by above commands.

\end{document}

On the other hand, when I try to use \raggedleft, no vertical space is added before this paragraph, but all following paragraphs are also aligned right (which is not what I intended):

\documentclass[final]{book}
\begin{document}

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus ut voluptatem at voluptatibus omnis ratione tenetur. A, voluptates. Enim beatae suscipit nesciunt sunt voluptatem, sit blanditiis nobis accusamus vitae nisi tempora odit eius molestias laborum obcaecati maiores optio placeat aut temporibus alias omnis porro minus ex! Illum dolores, explicabo assumenda?

\raggedleft This text should be aligned to right side with no vertical space above it.

Some regular text which should not be affected by above commands.

\end{document}

I am not sure how I can un-align text to default (justify) after using \raggedleft.

Is there any way to align text to right, without adding additional vertical space or affecting all text that follows after that alignment?

2

Try

{\raggedleft text\dots \par}

if you want the paragraph aligned to the right.

\documentclass{article}

\begin{document}
  Right-aligned wants \verb|\raggedleft|:\par
  {\raggedleft text \par}
  Left-aligned wants \verb|\raggedright|:\par
  {\raggedright text \par}
\end{document}

left-right right-left

3

You can keep \raggedright in a group, just make sure the end of paragraph is in the group so:

 {\raggedright text..... \par}
  • I have tried keeping this in a group, but I didn't think about adding \par at the end. I am not sure why it is needed, but it works (with \raggedleft as @cfr noted). – Rafal Oct 25 '14 at 16:36
  • 1
    @Rafal I think it is because TeX figures out what to do with the paragraph only at the end of that paragraph. So whatever is active when the paragraph ends affects the entire thing. Hence if you say {\tiny some text}\par some more you will get a bigger space between the lines than if you say {\tiny some text\par}some more because the value of \baselineskip depends on its value when \par is issued (or you leave a blank line or whatever). – cfr Oct 25 '14 at 16:42
  • @Rafal oh right/left oops :-) – David Carlisle Oct 25 '14 at 16:51
  • 1
    @Rafal a blank line and \par are the same thing, it's often easier to use the \par form in macros and the blank line in the document but they both make a \par token – David Carlisle Oct 25 '14 at 17:45
  • 1
    @Rafal You could use a blank line so long as it was still within the group i.e. before the closing }. – cfr Oct 25 '14 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.