对齐问题

对齐问题

有没有办法将这个例子中的电话号码和电子邮件对齐?该怎么做?我已经很久没有使用过 LaTeX 了。

在此处输入图片描述

\documentclass{article}
\usepackage[a4paper, left=2.5cm, top=2cm, bottom=2cm]{geometry}

% need this for Croatian letters
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}

\pagestyle{empty}       % neither header nor footer is shown

\usepackage{sectsty}
\sectionfont{\rmfamily\bfseries\scshape}
\subsectionfont{\rmfamily\mdseries\itshape\large}

\usepackage[bitstream-charter]{mathdesign}
\usepackage[scaled=0.85]{beramono}

% customizing lists
\renewenvironment{itemize}{
    \begin{list}{}{
        \setlength{\leftmargin}{1.5em}
        \setlength{\itemsep}{0.25em}
        \setlength{\parskip}{0pt}
        \setlength{\parsep}{0.25em}
                  }
                          }
                     {
    \end{list}
                         }
% stops paragraphs (section titles) being indented
\setlength\parindent{0em}

\begin{document}
{\huge JOHN DOE}

\vspace{0.5cm}
\begin{minipage}[t]{0.5\textwidth}
Long street 50\\12345 Town\\Country\\
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
Mobile: +123 45 678 9012\\Phone: +123 4 5678 901\\Email: \texttt{[email protected]}
\end{minipage}

\end{document}

答案1

另一种选择是使用tabbing环境:

\documentclass{article}
\usepackage[a4paper, left=2.5cm, top=2cm, bottom=2cm]{geometry}

% need this for Croatian letters
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}

\pagestyle{empty}       % neither header nor footer is shown

\usepackage{sectsty}
\sectionfont{\rmfamily\bfseries\scshape}
\subsectionfont{\rmfamily\mdseries\itshape\large}

\usepackage[bitstream-charter]{mathdesign}
\usepackage[scaled=0.85]{beramono}

% customizing lists
\renewenvironment{itemize}{
    \begin{list}{}{
        \setlength{\leftmargin}{1.5em}
        \setlength{\itemsep}{0.25em}
        \setlength{\parskip}{0pt}
        \setlength{\parsep}{0.25em}
                  }
                          }
                     {
    \end{list}
                         }
% stops paragraphs (section titles) being indented
\setlength\parindent{0em}

\begin{document}
{\huge JOHN DOE}

\vspace{0.5cm}
\begin{minipage}[t]{0.5\textwidth}
Long street 50\\12345 Town\\Country\\
\end{minipage}%
\begin{minipage}[t]{0.5\textwidth}
\begin{tabbing}
Mobile:\ \= +123 45 678 9012 \\
Phone:\> +123 4 5678 901 \\
Email:\> \texttt{[email protected]}
\end{tabbing}
\end{minipage}

\end{document}

在此处输入图片描述

请注意,我删除了第一个之后的虚假空白\end{minipage}以防止过满\hbox

答案2

使用tabular环境:

\begin{tabular}[t]{l@{ }l}
  Mobile:&+123 45 678 9012\\
  Phone:&+123 4 5678 901\\
  Email:&\texttt{[email protected]}
\end{tabular}

[t] 表示环境的顶部对齐,@{ } 表示只留一点空间(默认的列分隔对我来说似乎太多了)。

相关内容