I am typesetting an entire math lecture script, where readability often requires me to indent just a line or two for a certain amount, which is ALWAYS different. I would like to have some way of controlling the indent of the next line by an & like in tables, or any other control character. I do not want to use tables though, I want it to look like normal text. It obviously has to work inside and outside of math environments, since they appear in text quite often for this project.

It should look something like this:

This is the first line.
     One more line.
              And another.

With the control charcters being in front of "is" and "line".

Is there an easy-to-use solution? I don't care if it is complicated to configure once, as long as the use is simple every time.

4 Answers 4


Most TeX compilers provide the feature \pdfsavepos that allows to record the position on the shipout page. It was introduced in pdfTeX and is nowadays available in pdfTeX, both modes DVI and PDF, XeTeX, and LuaTeX.

Because the position is not known, before the page is output, some kind of reference system is needed. Package zref-savepos of project zref provides an interface to the \pdfsavepos feature.

% \zsaveposx is defined since 2011/12/05 v2.23 of zref-savepos
\newcommand*{\SP}{% set position
  \zsaveposx{\thehposcnt s}%
\newcommand*{\UP}{% use previous position
  \zsaveposx{\thehposcnt u}%
  \zref@refused{\thehposcnt s}%
  \zref@refused{\thehposcnt u}%
  \kern\zposx{\thehposcnt s}sp\relax
  \kern-\zposx{\thehposcnt u}sp\relax


This \SP is the first line\\
     \UP One more \SP line\\
                  \UP And another.



Some remarks:

  • The label names are automatically chosen via the help of a counter. That makes the usage easier, because the user don't need to invent unique label names.

  • The internal position data are integer numbers with implicit unit sp.

  • \zref@refused marks the reference as used to allow LaTeX the notification for undefined references.

  • That did it! Thank you very much for this solution. It works just the way I want, at least for text. If used within math it does not work well with the automatic spacing, but I can work around that. Aug 28, 2012 at 19:29

For completeness, \phantom{<stuff>} is also a possibility:

enter image description here

\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\setlength{\parindent}{0pt}% For this example.
\lipsum[2]% Some dummy text.

This is the first line. \par
\leavevmode\phantom{This }One more line. \par
\leavevmode\phantom{This One more }And another.

\lipsum[2]% Some dummy text.

\leavevmode is required if the paragraph starts with \phantom.

  • 4
    +1 for explaining the need for \leavevmode.
    – Mico
    Aug 27, 2012 at 23:31
  • 1
    Just adding a link to this question for an example what will happen without \leavevmode and a detailed explanation why it is needed.
    – bluenote10
    Jun 16, 2015 at 15:56

Text mode

You could use the tabbing environment:


\newenvironment{Tabbing}{% see http://tex.stackexchange.com/a/16389/16595

\noindent This is a line before the \verb|Tabbing| environment.
    This \= One more \=\kill\\
    This \> is the first line. \\
         \> One more line. \\
         \>        \>And another.
This is a line after the \verb|Tabbing| environment.


Output for text mode

Math mode

For math I'd suggest the alignat environment:

\textrm{This } & \rlap{is the first line.} & & \\
               & \textrm{One more }        & &\textrm{line.} \\
               &                           & &\textrm{And another.}


Output for math mode

Use \(\displaystyle <math> \) inside \rlap to get back to math mode.

  • This helps. What can be a problem is that I need to encase the entire paragraph within the environment since it always adds a skip and a new line at the beginning of the environment. If someone finds a better solution it is always welcome. Until then I will see how I can work with this. Aug 27, 2012 at 21:19
  • Same problem with the alignat environment are the skips added before and after it. Is there a way to create a custom environment with the properties of either of the above, but without the skips before and after? Aug 27, 2012 at 21:30
  • See egreg's answer. Aug 27, 2012 at 21:43
  • I updated my answer for the text mode part. For the math mode you could change the length \abovedisplayshortskip, \belowdisplayshortskip, \abovedisplayskip and \belowdisplayskip as explained in Mathmode. Or just use the array environment. Or the T/tabbing environment with a lots of \(...\) … Can you provide an example on how you want to align your formulas? Aug 27, 2012 at 22:03

Yet another option is the tabto package. It requires you to define the tab positions explicitly, but has the advantage to work over paragraph boundaries, so it can be used, for instance, with itemize lists:


  This \tabto{4em}is the first line. \\
  \tabto{4em}One \tabto{7em}more line. \\
  \tabto{7em}And another.

    \item This \tab is the first line. 
    \item \tab One \tab more line. 
    \item \tab\tab And another.


enter image description here

  • Thanks daniel. This is useful! May 10, 2020 at 2:17

You must log in to answer this question.

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