使用回忆录自动使用章节、部分和标题的标题大写

使用回忆录自动使用章节、部分和标题的标题大写

我想使用 titlecaps 包自动格式化我的章节、部分、小节标题以及说明。如果我手动设置,它可以工作,但我似乎找不到重新定义章节和部分命令以使用 titlecaps 的方法。任何帮助(以及其他建议)都非常感谢。

这里是 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}

我使用文章样式作为标题的基础,并对其进行了一些自定义。我认为可以在那里集成 titlecap 命令,但我就是不知道该怎么做。

答案1

好吧,其实并没有我想象的那么难。设法让它工作了。其他解决方案使用 titlesec,但它与 memoir 不兼容。下面是工作示例。所有章节、部分和小节标题现在都使用 titlecaps,图中的标题也是如此。

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

相关内容