2

I'd like to use the titlecaps package to automatically format my chapter, section, subsection headings as well as captions. If I set it manually it works, but I can't seem to find a way to redefine the chapter and section commands to use titlecaps. Any help (as well as alternative suggestions) really appreciated.

Here an MWE:

\documentclass[12pt, a4paper]{memoir}
\usepackage{lipsum}
\usepackage[bookmarksnumbered, breaklinks=true, colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue, bookmarks=true]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\usepackage{titlecaps}
\usepackage{caption}

%%% CUSTOM STYLE FOR CHAPTER HEADLINES
\makeatletter
\makechapterstyle{article}{%
\chapterstyle{default}
\setlength{\beforechapskip}{3.5ex}
\renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
\setlength{\afterchapskip}{3.3ex}
\renewcommand{\printchaptername}{}
\renewcommand{\chapternamenum}{}
\renewcommand{\chapnumfont}{\normalfont\bfseries\Large}
\renewcommand{\chapnamefont}{\normalfont\bfseries\Large}
\renewcommand{\chaptitlefont}{\normalfont\bfseries\Large}
%%\renewcommand{\formatchaptertitle}[1]{\titlecap{#1}}
\renewcommand{\printchapternum}{}
\renewcommand{\afterchapternum}{}
\renewcommand*{\printchapternum}{%
  \@hangfrom{\chapnumfont \thechapter\quad}}%
}
\makeatother
\chapterstyle{article}

%%% STYLE OF SECTIONS, SUBSECTIONS, AND SUB-SUBSECTIONS
\maxsecnumdepth{subsection} % chapters, sections, subsections numbered
\setsecheadstyle{\bfseries\raggedright}
\setsubsecheadstyle{\bfseries\raggedright}

\DeclareCaptionTextFormat{up}{\titlecap{#1}} % does not work
\captionsetup[table]{textfont=it, format=plain, labelsep=newline, skip=5pt, 
textformat=up}

\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\setulmargins{3.5cm}{*}{*} % sets start of text on page after ruled header
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{2cm}{*}{*} % start of rule header line on page
\setlrmarginsandblock{3.5cm}{2.5cm}{*} % left and right margins
\checkandfixthelayout

\begin{document}

\chapter{This is a nice chapter title it should be titelcaps}

\section{A first section title and should also be titlecaps}

\subsection{A subsection title, also in titlecaps}
\lipsum[3]

\section{\titlecap{This is a manually set title in caps, works but gives a warning}}
\lipsum[5]

\begin{figure}[htb]
    \centering
    \caption{This is a text for a caption and should be title caps - does not work}
    \label{fig:my_label}
\end{figure}

\end{document}

I'm using the article style as a basis for my headings and have customised it a little. I thought that it might be possible to integrate the titlecap command there, but I just can't figure out how.

1

Okay, so it wasn't so hard as I thought. Managed to get it working. Other solutions use titlesec, but that's not compatible with memoir. Below the working example. All chapter, section and subsection headings now use titlecaps, and captions in figures too.

\documentclass[12pt, a4paper]{memoir}
\usepackage{lipsum}
\usepackage[bookmarksnumbered, breaklinks=true, colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue, bookmarks=true]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\usepackage{titlecaps}
\usepackage{caption}

%%% CUSTOM STYLE FOR CHAPTER HEADLINES
\makeatletter
\makechapterstyle{article}{%
  \chapterstyle{default}
  \setlength{\beforechapskip}{3.5ex}
  \renewcommand*{\chapterheadstart}{\vspace{\beforechapskip}}
  \setlength{\afterchapskip}{3.3ex}
  \renewcommand{\printchaptername}{} % removes word chapter from chapter number
  \renewcommand{\chapnumfont}{\normalfont\bfseries\Large}
  \renewcommand\printchaptertitle[1]{\normalfont\bfseries\Large\titlecap{##1}} % title caps for chapter headings
  \renewcommand{\afterchapternum}{}
  \renewcommand*{\printchapternum}{%
    \@hangfrom{\chapnumfont \thechapter\quad}}%
}
\makeatother
\chapterstyle{article}

%%% STYLE OF SECTIONS, SUBSECTIONS, AND SUB-SUBSECTIONS
\maxsecnumdepth{subsection} % chapters, sections, subsections numbered

% set section headings to titlecaps
\newcommand\sectioncaps[1]{%
  \bfseries\raggedright\titlecap{#1}%
}
% set subsection headings to titlecaps
\newcommand\subsectioncaps[1]{%
  \bfseries\raggedright\titlecap{#1}%
}
\setsecheadstyle{\sectioncaps}
\setsubsecheadstyle{\subsectioncaps}

%%% set figure captions to use titlecaps
\DeclareCaptionTextFormat{up}{\titlecap{#1}}
\captionsetup[figure]{textformat=up}

\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\setulmargins{3.5cm}{*}{*} % sets start of text on page after ruled header
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{2cm}{*}{*} % start of rule header line on page
\setlrmarginsandblock{3.5cm}{2.5cm}{*} % left and right margins
\checkandfixthelayout

\begin{document}

\chapter{This is a nice chapter title it should be titelcaps}

\section{A first section title and should also be titlecaps}

\subsection{A subsection title, also in titlecaps}
\lipsum[3]

\begin{figure}[htb]
    \centering
    \caption{This is a text for a caption and should be title caps}
    \label{fig:my_label}
\end{figure}

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.