如何在 moderncv 中将章节标题左对齐?

如何在 moderncv 中将章节标题左对齐?

我正在尝试将基于 moderncv 的简历中的小节标题左对齐。

梅威瑟:

\documentclass{moderncv}
\usepackage[utf8]{inputenc}

\moderncvstyle{classic}
\moderncvcolor{blue}

\firstname{John}
\familyname{Doe}
\begin{document}

% These two lines have no effect
\renewcommand*{\subsectionfont}{\raggedright\large\mdseries\upshape}
\renewcommand*{\subsectionstyle}[1]{{\raggedright\subsectionfont

\subsection{Lorem ipsum dolor sitamet, consectetur adipiscing elit. Praesent varius nisl iaculis pellentesque dignissim. Aliquam fringilla accumsan mauris et aliquam.}

\end{document}

包括导致以下错误(对于和titlesec重复两次)\paragraph\subparagraph

! Undefined control sequence.
<argument> \subsubsection
l.1275 \ttl@extract\subsubsection
\textcolor{color1}{#1}}}

\raggedright在开头添加\subsection会导致错误(日志档案)

\subsection{\raggedright Lorem ipsum dolor sitamet, consectetur adipiscing elit. Praesent varius nisl iaculis pellentesque dignissim. Aliquam fringilla accumsan mauris et aliquam.}

答案1

有一种可能性是,该\RRsubsection命令的定义方式与标准类似\subsection,但会将标题排版得参差不齐:

\documentclass{moderncv}
\usepackage[utf8]{inputenc}

\moderncvstyle{classic}
\moderncvcolor{blue}

\firstname{John}
\familyname{Doe}

\makeatletter
\NewDocumentCommand{\RRsubsection}{sm}{%
  \par\addvspace{1ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{subsection}{#2}%
  \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    \raggedleft\hintstyle{} & \raggedright{\strut\subsectionstyle{#2}}%
  \end{tabular}%
  \par\nobreak\addvspace{0.5ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother

\begin{document}

\section{Test section}
\subsection{Lorem ipsum dolor sitamet, consectetur adipiscing elit. Praesent varius nisl iaculis pellentesque dignissim. Aliquam fringilla accumsan mauris et aliquam.}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description} 
\RRsubsection{Lorem ipsum dolor sitamet, consectetur adipiscing elit. Praesent varius nisl iaculis pellentesque dignissim. Aliquam fringilla accumsan mauris et aliquam.}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description} 

\end{document}

在此处输入图片描述

相关内容