1

1) The latex code I currently have and the corresponding output

\def\lineA{Email   \ \ \ Lorem ipsum dolor sit amet}
\def\lineB{Phone   \ \ \ Lorem ipsum dolor sit amet}
\def\lineC{Address \ \ \ Lorem ipsum dolor sit amet}
\def\lineD{Website \ \ \ Lorem ipsum dolor sit amet}
...
\lineA \\
\lineB \\
\lineC \\
\lineD \\

This is producing the following results

enter image description here

2) The latex code I want and the corresponding output

\def\lineA{\width{20px}{Email}   \ \ \ Lorem ipsum dolor sit amet}
\def\lineB{\width{20px}{Phone}   \ \ \ Lorem ipsum dolor sit amet}
\def\lineC{\width{20px}{Address} \ \ \ Lorem ipsum dolor sit amet}
\def\lineD{\width{20px}{Website} \ \ \ Lorem ipsum dolor sit amet}
...
\lineA \\
\lineB \\
\lineC \\
\lineD \\

That should hopefully be producing the following results

enter image description here

How can I achieve this?

AlanSTACK
  • 175

3 Answers3

1

What you're looking for here (instead of \width) is \makebox[<len>][<align>]{<stuff>}, which sets <stuff> inside a box of width <len> and a particular <align>ment (left, right, centred or stretched). The default is centred if you don't specify any <align>ment. You can specify <len> in pixels, but there are other, standard lengths typically used, depending on whether you want something absolute (like points) or relative (like ems). See What are the various units (ex, em, in, pt, bp, dd, pc) expressed in mm?.

In your particular case, use something like

\def\lineA{\makebox[5em][l]{Email}   Lorem ipsum dolor sit amet}
\def\lineB{\makebox[5em][l]{Phone}   Lorem ipsum dolor sit amet}
\def\lineC{\makebox[5em][l]{Address} Lorem ipsum dolor sit amet}
\def\lineD{\makebox[5em][l]{Website} Lorem ipsum dolor sit amet}

If you want to calculate the maximum width automatically you can consider using eqparbox's \eqmakebox[<tag>][<align>]{<stuff>} where you use the same <tag> for each element you want to consider.

Werner
  • 603,163
1

The answer above is a mix of LaTeX and TeX code. I show you pure TeX code:

\def\lineA{\leavevmode\hbox to5em{Email\hss}   Lorem ipsum dolor sit amet\par}
\def\lineB{\leavevmode\hbox to5em{Phone\hss}   Lorem ipsum dolor sit amet\par}
\def\lineC{\leavevmode\hbox to5em{Address\hss} Lorem ipsum dolor sit amet\par}
\def\lineD{\leavevmode\hbox to5em{Website\hss} Lorem ipsum dolor sit amet\par}

\lineA \lineB \lineC \lineD

wipet
  • 74,238
1

I guess you want a tabular

\documentclass{article}

\begin{document}

\begin{tabular}{@{} l l @{}} Email & \texttt{name@example.com} \ Phone & (888) 555 99 99 99 \ Address & 99 Some Street, Sometown \ Website & \texttt{https://name.example.com} \end{tabular}

\end{document}

enter image description here

egreg
  • 1,121,712