1

I'm trying to left-justify a subsection heading in my moderncv-based CV.

MWE:

\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}

Including titlesec leads to the following error (it is repated twice for \paragraph and \subparagraph)

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

Adding \raggedright at the beginning of the \subsection command causes errors (logfile).

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

1 Answer 1

1

Here's one possibility; the \RRsubsection command was defined in a similar fashion to the standard \subsection, but will typeset the title ragged right:

\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}

enter image description here

4
  • I'm sorry, I may have expressed myself unclearly. I don't want to change where the heading starts on the left side, I want to disable justification on the right one (i.e. the effect of \raggedright.
    – Nova
    Feb 20, 2015 at 13:00
  • @Erik Ah. And what do you want to replace \raggedright with? Feb 20, 2015 at 13:01
  • I don't want to replace \raggedright by anything; I'm looking for a way to apply it to a heading.
    – Nova
    Feb 20, 2015 at 13:02
  • @Erik Please see my updated answer. Feb 20, 2015 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .