我喜欢一个特定的描述对齐:
- 标签右对齐
- 描述左对齐
我LaTeX
一直都是手动操作,所以我想配置description
环境来执行此操作。有人能给点建议吗?
\documentclass{article}
\usepackage{enumitem}
\begin{document}
I'd like a description alignment like this:
\begin{tabular}{rl}
\textbf{E1:} & Example item 1 \\
\textbf{Long E2:} & Example item 2 \\
\textbf{Long long E3:} & Example item 3 \\
\end{tabular}
How to do it with description environment
or enumitem settings?
\end{document}
答案1
enumitem
以下是使用 和的解决方案calc
:
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{enumitem, calc}
\begin{document}
I'd like a description alignment like this:
\begin{tabular}{rl}
\textbf{E1:} & Example item 1 \\
\textbf{Long E2:} & Example item 2 \\
\textbf{Long long E3:} & Example item 3 \\
\end{tabular}
How to do it with description environment
or enumitem settings?
\begin{description}[labelwidth= \widthof{\bfseries Long long E3:}, align =right]%
\item[E1:] Example item 1
\item[Long E2:] Example item 2
\item[Long long E3:] Example item 3
\end{description}
\end{document}