编辑

编辑

这就是我所拥有的:

\documentclass[a4paper,11pt,oldfontcommands]{memoir}

\setlrmarginsandblock{2.5cm}{1.5cm}{1} 
\setulmarginsandblock{2.5cm}{*}{1} 
\setheadfoot{2\onelineskip}{\footskip}
\checkandfixthelayout
\usepackage{pdfpages}
\usepackage{tikz}
\usetikzlibrary{positioning}

%%%%%%
% CHAPTER STYLES
%%%%%%
\makechapterstyle{simple}{
  \renewcommand*{\printchaptername}{}
  \setlength{\afterchapskip}{1cm}
  \renewcommand*{\printchaptertitle}[1]{\flushleft\chaptitlefont##1}
  }

\makechapterstyle{box}{
  \setlength{\midchapskip}{-58pt}
  \setlength{\afterchapskip}{1cm}
  \renewcommand*{\printchaptername}{}
%  \renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
  \renewcommand*{\printchapternum}{
    \flushleft
    \begin{tikzpicture}
      \draw[fill,color=black] (0,0) rectangle (2cm,2cm);
      \draw[color=white] (1cm,1cm) node { \chapnumfont\thechapter };
    \end{tikzpicture}
  }

 % \renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
 \renewcommand*{\printchaptertitle}[1]{%\flushright\chaptitlefont##1}
 \chaptitlefont\parbox[c]{\textwidth}{\hspace{3cm}##1}}
 }

 \chapterstyle{simple}

%%%%%%
% gør at subsections også nummeres
%%%%%%
\setsecnumdepth{subsection}
\usepackage{parskip}    % Bruges til at lave større mellemrum mellem afsnit
\usepackage{graphicx}   % Required for including pictures
\usepackage{framed}     % Laver boxe 
\usepackage{setspace} % Kan lave forskellige mellemrum mellem linjerne
\usepackage[utf8x]{inputenc}    % Hvis du benytter windows i stedet for linux, så skift utf8 ud med latin1. Tillader danske tegn.
\usepackage{float}      % Allows putting an [H] in \begin{figure} to specify the exact location of the figure
\usepackage{wrapfig}    % Allows in-line images such as the example fish picture

\usepackage[danish]{babel}

\usepackage{lipsum}                         % Used for inserting dummy 'Lorem ipsum' text into the template
\linespread{1.2} % Line spacing
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

%%%%%%
% PAGESTYLE
%%%%%%
\makepagestyle{bachelor}
\makepsmarks{bachelor}{
  \createmark{chapter}      {both}{shownumber}{}{. \ }
  \createmark{section}      {both}{shownumber}{}{. \ }
}
\makeoddhead{bachelor}%
  {}%
  {}%
  {\rightmark}%
\makeevenhead{bachelor}%
  {\leftmark}%
  {}%
  {}

\makeoddfoot{bachelor}{}%
  {\thepage}{}
\makeevenfoot{bachelor}{}%
  {\thepage}{}

\makeheadrule{bachelor}{\textwidth}{\normalrulethickness}

% \setsecheadstyle{\large\bfseries\raggedright}
% \setsubsecheadstyle{\normalsize\bfseries\raggedright}

%%%%%%
% Ændring af indholdsfortegnelsen og litteraturlisten
%%%%%%
\addto\captionsdanish{\renewcommand\contentsname{INDHOLDSFORTEGNELSE}}
\addto\captionsdanish{\renewcommand*{\bibname}{LITTERATURLISTE}}

\nouppercaseheads
\pagestyle{bachelor}

\begin{document}

\pagenumbering{roman}
\title{Test}

%----------------------------------------------------------------------------------------
%   -1.0 Preface
%----------------------------------------------------------------------------------------
\chapter*{Preface}
\lipsum[1-2]


%----------------------------------------------------------------------------------------
%   -2.0 Table of contents
%----------------------------------------------------------------------------------------
\newpage\thispagestyle{empty}\mbox{}\newpage
\tableofcontents*
\newpage\thispagestyle{empty}\mbox{}
\newpage 

\chapterstyle{box}

%----------------------------------------------------------------------------------------
%   1. Intro
%----------------------------------------------------------------------------------------
\pagenumbering{arabic}
\chapter{Intro}
\lipsum[1-2]
\subsection{Intro with upper and lower case}
\lipsum[1-1]

\end{document}

评论:

\uppercase{\chapter{A chapter}}我只想写 , 而不是写 , \chapter{Intro}并将章节标题改为大写。我搜索了很多地方,但没有找到可行的解决方案。

为了清楚起见,这里有两种不同的章节样式。一种是\chapterstyle{simple},另一种是\chapterstyle{box}\chapterstyle{box}使用 会创建一个黑框,里面有章节号。该框位于章节标题的左侧,我希望章节标题自动使用大写字母,而不是每次都使用\uppercase{\chapter{A Chapter}}

编辑:在顶部添加了一些行,这对于章节名称的对齐很重要,与黑框相比。

解决了: 我插入了来自用户“cfr”的所选答案的编辑 2。我确实使用 hyperref,所以一开始没有用,但他建议如果我使用了 hyperref,我应该使用回忆录指南第 158 页的代码,现在运行完美!<3

答案1

我不确定您是否也希望将章节名称改为大写,或者只将标题改为大写,所以我将两者都改了:

\documentclass[a4paper,11pt,oldfontcommands]{memoir}

\makeatletter
 \renewcommand\printchaptername{%
   \raggedright\chapnamefont\MakeUppercase{\@chapapp}}
\makeatother
\renewcommand*{\printchaptertitle}[1]{\flushleft\chaptitlefont\MakeUppercase{#1}}

\begin{document}

  \chapter{A chapter}

\end{document}

全部大写

编辑

如果要使用box您定义的样式将章节大写,您可以尝试以下方法。有关生成最小工作示例的信息,请参阅这些说明

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}

\makechapterstyle{box}{%
  \setlength{\midchapskip}{-58pt}%
  \setlength{\afterchapskip}{20mm}%
  \renewcommand*{\printchaptername}{}%
  \renewcommand*{\printchapternum}{%
    \flushleft
    \begin{tikzpicture}
      \draw [fill=black] (0,0) rectangle (2cm,2cm);
      \node [text=white] at (1cm,1cm) { \chapnumfont\thechapter };
    \end{tikzpicture}}%
  \renewcommand{\printchaptertitle}[1]{%
    \begin{minipage}{\textwidth-20mm}
        \hspace*{30mm}\chaptitlefont\MakeUppercase{##1}\par
    \end{minipage}}%
  }

\chapterstyle{box}

\begin{document}

  \chapter{A chapter}

  Some text. What happens to the text?

\end{document}

带大写标题的方框数字

编辑2

要使 ToC 条目大写,您可以尝试:

\documentclass[a4paper,11pt,oldfontcommands]{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}
\makechapterstyle{box}{%
  \setlength{\midchapskip}{-58pt}%
  \setlength{\afterchapskip}{20mm}%
  \renewcommand*{\printchaptername}{}%
  \renewcommand*{\printchapternum}{%
    \flushleft
    \begin{tikzpicture}
      \draw [fill=black] (0,0) rectangle (2cm,2cm);
      \node [text=white] at (1cm,1cm) { \chapnumfont\thechapter };
    \end{tikzpicture}}%
  \renewcommand{\printchaptertitle}[1]{%
        \hspace*{30mm}\chaptitlefont\MakeUppercase{##1}}}
\makeatletter
  \settocpreprocessor{chapter}{% see page 158 of the manual
    \let\tempf@rtoc\f@rtoc%
    \def\f@rtoc{%
      \MakeTextUppercase{\tempf@rtoc}}%
  }
\makeatother

\chapterstyle{box}

\begin{document}

  \tableofcontents

  \chapter{A chapter}

  Some text. What happens to the text?

\end{document}

目录中的大写字母

相关内容