5

I'd like to use \phantom{} for spacing inside an itemize environment. It however breaks a line. What should I do? The best solution I found was to replace \phantom{} by \hspace{} which is quite fastidious.

Example of code:

\documentclass{beamer}
\begin{document}

\begin{frame}[t]{Title}
    \begin{itemize}
        \item a first item
        \item[~] \phantom{a first} atem
    \end{itemize}
\end{frame}

\end{document}

The goal is to get the words item and atem perfectly aligned (which I find useful in beamer presentations).

5
  • 1
    You could place the item content in a \mbox{} including the phantom part. Jan 31, 2020 at 6:13
  • 5
    It is not obvious to me why you want to put spaces inside an item. You should explain what you want to get instead of looking for the solution for the method that you are trying to get it. Moreover, a \phantom{} at the beginning of \item will not break the line (as your example shows) unless it contains a long sentence... so?
    – Fran
    Jan 31, 2020 at 6:18
  • What TeX distribution are you using?
    – egreg
    Jan 31, 2020 at 9:17
  • I was indeed using an old TeX distribution Jan 31, 2020 at 10:41
  • An alternative method could be ` \item a first \parbox[t]{4em}{item\\atem}`
    – Fran
    Jan 31, 2020 at 23:29

1 Answer 1

3

Up to the LaTeX release in December 2018, commands such as \phantom or \thinspace didn't initiate L-R mode (horizontal mode, in TeXspeak); now they do.

From your description, I deduce you're running an old TeX distribution. Update.

In the meantime, do \mbox{\phantom{a first}}.

What happens? When LaTeX processes \item, it goes into “between paragraphs mode” (vertical mode in TeXspeak) and only resumes L-R mode when something needs to be typeset (the main purpose of this is to allow \label without adding spurious spaces). However, with an old LaTeX kernel, \phantom would not trigger L-R mode, but rather form an empty (because of \phantom) line. Only atem would start L-R mode in your context.

With a newer LaTeX kernel the above simply doesn't happen.

2
  • 1
    @Dr.ManuelKuehner Your edit was invalid, sorry.
    – egreg
    Jan 31, 2020 at 11:18
  • Ah, I see. Sorry :). Jan 31, 2020 at 12:05

You must log in to answer this question.

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