有什么方法可以将溢出的行与句子中的特定部分对齐
我想在 MS Office 下对齐第二行....
\textbf{Software} --- MS Office Powerpoint, Software 1, Software 2, Software 3, Software 4, Software 5, Software 6, Software 7, etc. etc.
截至目前,我正在这样做:
\textbf{Software} --- MS Office Powerpoint, Software 1, Software 2, Software 3, Software 4,\\
\hspace{60pt}Software 5, Software 6, Software 7, etc. etc.
答案1
您可以使用tabular
环境。不过,请注意不要让盒子太满。
\documentclass{article}
\begin{document}
\noindent
\begin{tabular}{r@{\ }l}
\textbf{Software} --- & MS Office Powerpoint, Software 1, Software 2, Software 3, Software 4,\\
& Software 5, Software 6, Software 7, etc. etc.
\end{tabular}
\end{document}
答案2
您需要一个经过修改的description
环境。
\documentclass{article}
\usepackage[pass,showframe]{geometry}% just for the example
\usepackage{enumitem}
\newlength{\mydesclen}
\newenvironment{mydesc}[1]
{\settowidth{\mydesclen}{\textbf{#1} --- }%
\newcommand{\mitem}[1]{\item[\normalfont\textbf{##1} --- ]}%
\begin{description}[
labelwidth=\mydesclen,
leftmargin=\mydesclen,
labelsep=0pt,
align=right]}
{\end{description}}
\begin{document}
\begin{mydesc}{Hardware}
\mitem{Software} MS Office Powerpoint, Software 1, Software 2, Software 3,
Software 4, Software 5, Software 6, Software 7, etc. etc.
\mitem{Hardware} Mac, Dell, Casio, Hewlett \& Packard, long long long long
long long long long long long long text
\end{mydesc}
\end{document}
可以避免指定最广泛的术语。
\documentclass{article}
\usepackage[pass,showframe]{geometry}% just for the example
\usepackage{enumitem,environ}
\newlength{\mydesclen}
\NewEnviron{mydesc}{%
\global\mydesclen=0pt
\setbox0=\vbox{\hbadness=10000
\def\mitem##1{\sbox2{\textbf{##1} --- }%
\ifdim\wd2>\mydesclen \global\mydesclen=\wd2 \fi}
\BODY}
\def\mitem##1{\item[\normalfont\textbf{##1} --- ]}%
\begin{description}[
labelwidth=\mydesclen,
leftmargin=\mydesclen,
labelsep=0pt,
align=right]
\BODY
\end{description}}
\begin{document}
\begin{mydesc}
\mitem{Software} MS Office Powerpoint, Software 1, Software 2, Software 3,
Software 4, Software 5, Software 6, Software 7, etc. etc.
\mitem{Hardware} Mac, Dell, Casio, Hewlett \& Packard, long long long long
long long long long long long long text
\end{mydesc}
\end{document}