3

Obviously the following does not do what I have described in the title.

\documentclass{article}

\begin{document}

\begin{flushright}
\begin{center}
\vspace{1cm}
Here is the first line.\\
Second line.
\end{center}
\end{flushright}
\end{document}

In other words, I would like an output like this:

enter image description here

  • 2
    It's not very clear: you want a centred block, but each line inside the block has to be flushright? – Bernard Jan 9 '17 at 10:19
  • @Bernard I updated the question. – Name Jan 9 '17 at 10:29
8

You can use tabular often addresses in frontmatter are set this way.

enter image description here

\documentclass{article}

\begin{document}


\begin{center}
\begin{tabular}{@{}l@{}}
Here is the first line.\\
Second line.
\end{tabular}
\end{center}
\begin{flushright}
\begin{tabular}{@{}c@{}}
Here is the first line.\\
Second line.
\end{tabular}
\end{flushright}
\end{document}
6

Maybe you expect a right aligned block of centred lines. If so, you could use varwidth:

\documentclass{article}
\usepackage{varwidth}
\begin{document}

\begin{flushright}
\begin{varwidth}{\linewidth}\centering
Here is the first line.\\
Second line.
\end{varwidth}
\end{flushright}
\end{document}

Right aligned block of centred lines

  • That's a bit of overkill: since you're specifying the line breaks, a tabular is easier. – egreg Jan 9 '17 at 10:33
  • @egreg: As long as you really have only manually specified line breaks and as long as it doesn't matter that every line is a group on its own and as long a you have not changed e.g. line stretching of tabular rows in the document preamble. Sometimes pretended overkill may become a prefered solution. – Schweinebacke Jan 9 '17 at 10:53
  • I didn't mean the solution is bad! To the contrary, I upvoted it. – egreg Jan 9 '17 at 11:24

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.