I found this answer which shows how to have a line with left, center, and right-aligned text. The thing is that I want essentially two lines, or a line break within each component.
This is fine, except that the first line's middle component is in large text which causes weird vertical alignment, so I'd like to know if and how it'd be possible to vertically-align everything to the top so everything is flush at the top, which in this case would mean that the center component descends farther down than the left and right components. I'm mainly curious to learn more about latex but also to see how it would look, maybe the current typesetting looks best (I'm open to opinions).
To be clear, I want something like this, where everything is aligned at the top:
I realized that \makebox
doesn't allow line breaks so I did this by creating two \toplines
.
\documentclass{article}
\newcommand{\topline}[3]{%
\noindent%
\makebox[0pt][l]{#1}%
\makebox[\textwidth][c]{#2}%
\makebox[0pt][r]{#3}}
\begin{document}
\topline{123 Main Street}%
{\LARGE {FIRST MIDDLE LAST}}%
{\textnormal{(555) 123 -- 4567}}
\topline{Los Angeles, CA}%
{[email protected]}%
{somesite.com}
\end{document}
I found that \parbox
has vertical-alignment parameters, and saw the top answer which uses \parbox
so I attempted using that, but I am misunderstanding something as I can't get things to vertically align to the top. The result seems similar:
\documentclass{article}
\newcommand{\topline}[3]{%
\parbox[t]{.333\textwidth}{\raggedright#1}%
\parbox[t]{.333\textwidth}{\centering#2}%
\parbox[t]{.333\textwidth}{\raggedleft#3}}
\begin{document}
\topline{123 Main Street \\ Los Angeles, CA}%
{{\LARGE {FIRST MIDDLE LAST}} \\ [email protected]}%
{\textnormal{(555) 123 -- 4567} \\ somesite.com}
\end{document}
I learned about \raisebox
which I think allowed me to achieve what I want, but the manner in which I'm using it feels very ad-hoc. For example, I just guessed the unit by which to raise it to be 1ex
, and I'm not positive if everything is completely flush. It seems to me like it is. I'd love to know if 1ex
really is the perfect/exact unit and if so why, or if it's more the case that anything above some unit would flush at the top and go no further.
If this is the best way to do this, then that's fine with me, but it feels pretty hacky and arbitrary.
\documentclass{article}
\newcommand{\topline}[3]{%
\noindent%
\raisebox{1ex}{\parbox[t]{.333\textwidth}{\raggedright#1}}%
\parbox[t]{.333\textwidth}{\centering#2}%
\raisebox{1ex}{\parbox[t]{.333\textwidth}{\raggedleft#3}}}
\begin{document}
\topline{123 Main Street \\ Los Angeles, CA}%
{{\LARGE {FIRST MIDDLE LAST}} \\ [email protected]}%
{\textnormal{(555) 123 -- 4567} \\ somesite.com}
\end{document}
I realize I'm probably doing this completely wrong, so I'd appreciate any help! Maybe I should be using entirely different commands or environments, or maybe this kind of thing just isn't possible.
I'm aware of fancyhdr
and I was going to attempt using it, but what I have seemed simple enough to avoid having to bring in an entirely separate package and figuring out how it works and making sure it works well with my existing document, but if it really is the best way, then I'll be happy to look into it.
\parbox[t]{.333\textwidth}{Foobar}
instead of\parbox[t][][t]
for top alignment. The second[t]
only makes sense if you specify a total height with the second optional argument.\documentclass{...}
, the required\usepackage
's,\begin{document}
, and\end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.fontspec
really necessary to show your problem, which is just about alignment of\parbox
es and the like, which are part of the LaTeX kernel? You should always provide minimal working examples, which only contain the bare necessities for your code to demonstrate your issue. Sorry if that wasn't clear from my second comment.