我想用自动方法替换手动列宽方法(即),即从 中减去 的宽度后0.9\textwidth
确定剩余部分。此外,我需要将文本缩进多行,如此输出所示。\textwidth
\cvitem{Title}
\textwidth
\RequirePackage{luatex85}
\documentclass[12pt,a4paper,sans,fullrules]{moderncv}
\usepackage[tuenc]{fontspec}
\moderncvstyle{banking}
\name{Diaa}{Abidou}
\begin{document}
\makecvtitle
\section{Education}
\smallskip
\subsection{Philosophy of Doctor}
\cventry{date}{Ph.D.}{University}{city}{}{}
\cvitem{Title}{\begin{tabular}[t]{@{}p{0.9\textwidth}@{}}
some long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long title
\end{tabular}
}
\end{document}
答案1
在banking
样式中,该命令\cvitem
定义为
\renewcommand*{\cvitem}[3][.25em]{%
\ifthenelse{\equal{#2}{}}{}{\hintstyle{#2}: }{#3}%
\par\addvspace{#1}}
例如,您可以\mycvitem
使用以下命令定义一个新命令tabularx
:
\usepackage{tabularx}
\newcommand*{\mycvitem}[3][.25em]{%
\begin{tabularx}{\linewidth}{l{1ex}X}
\hintstyle{#2}: & & #3%
\end{tabularx}
\par\addvspace{#1}}
请注意,此命令不检查参数是否#2
为空。现在认为它不为空!
使用以下 MWE
\RequirePackage{luatex85}
\documentclass[%
12pt,
a4paper,
sans,
fullrules
]{moderncv}
\usepackage[%
% tuenc
]{fontspec}
\usepackage{tabularx} % <===============================================
\newcommand*{\mycvitem}[3][.25em]{% <===================================
\begin{tabularx}{\linewidth}{lp{1ex}X}
\hintstyle{#2}: & & #3%
\end{tabularx}
\par\addvspace{#1}} % <===============================================
\moderncvstyle{banking}
\name{Diaa}{Abidou}
\begin{document}
\makecvtitle
\section{Education}
\smallskip
\subsection{Philosophy of Doctor}
\cventry{date}{Ph.D.}{University}{city}{}{}
\cvitem{Title}{\begin{tabular}[t]{@{}p{0.9\textwidth}@{}}
some long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long title
\end{tabular}
}
\mycvitem{Title}{%
some long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long title
}
\mycvitem{longTitle}{%
some long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long title
}
\end{document}
得到结果: