2

I'm trying to align the following piece of text:

*Corresponding author
Name Nameson
name@mydomain.com

such that the two lower lines are horizontally aligned with the C, rather than the * in the first line. To this end, I have tried \hphantom{*}

MWE:

\documentclass[twoside]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[inner sep=0pt, below right, text width=\textwidth] {
                      \textsuperscript{*}Corresponding author\\
                      \hphantom{*}Name Nameson\\
                      \hphantom{*}name@mydomain.com};
    \end{tikzpicture}
\end{document}

but this has no effect on the horisontal alignment. Instead, it gives an additional linebreak, no matter what I use as argument to \hphantom.

How can I achieve the desired alignment?

1

Two ways, depending on desired alignment. In the first case, I just left-align a \Longunderstack of the desired text following the \textsuperscript{*}. In the second case, I \llap the \textsuperscript{*}.

\documentclass[twoside]{article}
\usepackage{pgfplots,stackengine}
\setstackEOL{\\}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\setstackgap{L}{1\baselineskip}
\draw (0,0) node[inner sep=0pt, below right, text width=\textwidth] {
                      \textsuperscript{*}\Longunderstack[l]{Corresponding author\\
                      Name Nameson\\
                      name@mydomain.com}};
    \end{tikzpicture}

    versus:\smallskip

    \begin{tikzpicture}
\draw (0,0) node[inner sep=0pt, below right, text width=\textwidth] {
                      \llap{\textsuperscript{*}}Corresponding author\\
                      Name Nameson\\
                      name@mydomain.com};
    \end{tikzpicture}
\end{document}

enter image description here

Egreg mentions that \hphantom does not start horizontal mode. Thus, to fix the problem using your original approach, one must merely leave vertical mode before invoking the \hphantom:

\documentclass[twoside]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[inner sep=0pt, below right, text width=\textwidth] {
                      \textsuperscript{*}Corresponding author\\
                      \leavevmode\hphantom{*}Name Nameson\\
                      \leavevmode\hphantom{*}name@mydomain.com};
    \end{tikzpicture}
\end{document}
1

\hphantom doesn't start horizontal mode and indeed you get blank lines instead of the space you want.

Instead of \hphantom, I recommend using tabular.

\documentclass[twoside]{article}
\usepackage{tikz}
\begin{document}

\noindent
\begin{tikzpicture}
\draw (0,0) node[
  outer sep=-1pt,
  inner sep=0pt,
  below right,
  text width=\textwidth
]{\begin{tabular}{@{}r@{}l@{}}
    * & Corresponding author\\
      & Name Nameson\\
      & name@mydomain.com
  \end{tabular}
};
\end{tikzpicture}

\end{document}

enter image description here

Note that \textsuperscript{*} is generally wrong, because the text mode asterisk is already in raised position.

If you want to use \hphantom, add \leavevmode in front of it.

\begin{tikzpicture}
\draw (0,0) node[
  outer sep=-1pt,
  inner sep=0pt,
  below right,
  text width=\textwidth
]{*Corresponding author\\
  \leavevmode\hphantom{*}Name Nameson\\
  \leavevmode\hphantom{*}name@mydomain.com};
\end{tikzpicture}

The output is the same.

  • I know it's a bit hacky, but it comes from the custom poster template that my institute uses. I'm trying not to change too much. – Mathias Kure Jul 26 '16 at 14:43

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.