![對齊 \emailfrom 內的兩行文本](https://rvso.com/image/298814/%E5%B0%8D%E9%BD%8A%20%5Cemailfrom%20%E5%85%A7%E7%9A%84%E5%85%A9%E8%A1%8C%E6%96%87%E6%9C%AC.png)
我對 TeX 很陌生,我正在嘗試使用 LaTeX 製作一封簡單的求職信。我已經下載了求職信的模板,它有一個名為 的組件(我不知道你如何稱呼這些東西)\emailfrom
。我的程式碼如下所示:
\emailfrom{ % Email address
[email protected] \\
[email protected] \\
[email protected]
}
這就是我目前所獲得的:
到目前為止我唯一不優雅的解決方案是:
\emailfrom{ % Email address
[email protected] \\
[email protected] \\
[email protected]
}
我希望能夠將第二封和第三封電子郵件與第一封電子郵件對齊。我怎樣才能實現這個目標?
很抱歉我的含糊之處,但我對 TeX 一無所知。
答案1
在沒有 MWE 的情況下未經測試。試試這樣的事情:
\emailfrom{% Email address
\begin{tabular}[t]{l}
[email protected] \\
[email protected] \\
[email protected]
\end{tabular}
}
要mailto: put
在序言中取得超連結和 \usepackage{hyperref}`,並使用
\href{mailto:your name}{first.email}
答案2
這是另一個「有趣」的答案,但不幸的是,它無法被接受,因為 LaTeX 指南中沒有解釋 TeX 原語(此處使用)。
% in preamble:
\def\emails#1{\vtop\bgroup\emailsA #1,,}
\def\emailsA#1,{\ifx,#1,\egroup\else\hbox{\ignorespaces#1}\expandafter\emailsA\fi}
% in document:
Emails: \emails{[email protected], [email protected], [email protected]}
答案3
也許是這樣的:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{etoolbox,hyperref}
\newcounter{email}
\newcommand{\emailfrom}[1]{%
\begingroup
\parindent 0pt%
\parbox{2cm}{Email:}%
\setcounter{email}{0}%
\renewcommand*{\do}[1]{%
\stepcounter{email}%
\ifnum\value{email}<2\relax%
\emailformat{##1}\par
\else
\hspace{2cm}\emailformat{##1}\par
\fi}%
\docsvlist{#1}
\endgroup}
\newcommand{\emailformat}[1]{\href{mailto:#1}{#1}}
\begin{document}
\emailfrom{% Email address
[email protected], [email protected], [email protected]}
\end{document}
它設定一個名為「電子郵件」的計數器,以便您可以使清單中的第一項的行為與後面的項目不同。使用該命令\emailformat
是為了讓您更輕鬆地設定電子郵件地址的樣式。\parindent
和 的參數\parindent
應該根據口味進行更改。 (如果您願意,它們可以合併到定義中,以便\emailfrom
您可以在發出命令時更改它們。)