2

The multline environment alignes the first line to the left, the last one to the right, while all the lines in between are simply centered. The result sometimes looks not satisfying, for example, when all the lines are just slightly wider that the half ot the text width.

Standard multline

What I am looking for is a tool to make it apper more "stairs-like", as in the picture below, but without adding manually chosen \hspace{...} into each line.

Adjusted multline

I know there are all kinds of exceptions such as lines too wide and so on, and I do not expect the solution to always make a perfect output, but there should be something that works in a "generic" case. Any ideas?

1

2 Answers 2

1

You can set each line in a macro that spreads them out "manually" using something like \setline[<align>]{<portion>}{<stuff>} as defined below:

enter image description here

\documentclass{article}

\usepackage{lipsum}

\newcommand{\setline}[3][c]{\hspace*{#2\linewidth}\makebox[0pt][#1]{#3}}
\newenvironment{spreadlines}
  {\par
   \setlength{\parindent}{0pt}%
   \obeylines}
  {\par}

\begin{document}

\lipsum[1]

\begin{spreadlines}
  \setline[l]{0}  {The first line is aligned to the left.}
  \setline   {.25}{The second line is (not) centred.}
  \setline   {.5} {And so is the third one.}
  \setline   {.75}{As well as the fourth --- not centred!}
  \setline[r]{1}  {The last line is aligned to the right.}
\end{spreadlines}

\lipsum[2]

\end{document}

It would probably be possible to determine the value {<portion>} automatically, if needed.

0

Package mathtools provide option \shoveleft[<ofset>]{<part of equation>} by which you can easy obtain stairs like multline: enter image description here

Code based on example in mathtools manual (pp 17):

\documentclass[11pt, border=1mm,
               preview]{standalone}
    \usepackage{mathtools}

    \begin{document}
\[
\begin{multlined}
\framebox[.65\columnwidth]{First line} \\
\shoveleft[1cm]{\framebox[.5\columnwidth]{Second line} } \\
\shoveleft[2cm]{\framebox[.5\columnwidth]{Second line} } \\
\shoveleft[3cm]{\framebox[.5\columnwidth]{Second line} } \\
\framebox[.65\columnwidth]{Last line}
\end{multlined}
\]
    \end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .