章节标题样式

章节标题样式

我正在尝试重新设计章节标题。我希望章节编号垂直延伸两行。这样,对于较长的章节名称,编号位于整个名称之前。此外,我想在编号和章节名称之间添加一条垂直线。我尝试过并在论坛上搜索了一些示例,但没有成功。

有人知道吗?

\documentclass{scrreprt}

\usepackage[
includemp,
                  showframe,
                  reversemp,
            paperwidth=20.1cm,
            paperheight=25.80cm,
            top=2.30cm,
            bottom=3.4cm,
            inner=2.7cm,
            outer=2.7cm,
            marginparwidth=1.6cm, % Fixed for now
            marginparsep=0.4cm
            ]{geometry}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother


\renewcommand*{\chapterformat}{\makebox[0pt][r]{\chapappifchapterprefix{\ 
}\thechapter\autodot\hskip\marginparsep}}%
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}

\begin{document}


\chapter{test}
\chapter{Test with a longer name, test with a longer name, test with a 
longer name}
\section{test}
\section{test}


\end{document}

在此处输入图片描述

答案1

我不太明白你想要什么。也许你想要:

\documentclass{scrreprt}

\usepackage[
  includemp,
  showframe,
  reversemp,
  paperwidth=20.1cm,
  paperheight=25.80cm,
  top=2.30cm,
  bottom=3.4cm,
  inner=2.7cm,
  outer=2.7cm,
  marginparwidth=1.6cm, % Fixed for now
  marginparsep=0.4cm
]{geometry}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother

\usepackage{graphicx}
\renewcommand*{\chapterformat}{%
  \makebox[0pt][r]{%
    \scalebox{2}{% double size the chapter number
      \chapappifchapterprefix{\ }\thechapter\autodot
      \rule{1pt}{\ht\strutbox}% add a rule behind the number
    }%
    \hskip\marginparsep
  }%
}
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}

\RedeclareSectionCommand[
  beforeskip=-1sp plus -1sp minus 1sp,% remove the vertical skip before the chapter heading
]{chapter}

\begin{document}

\chapter{test}
\chapter{Test with a longer name, test with a longer name, test with a 
longer name}
\section{test}
\section{test}

\end{document}

第一个建议

或者

\documentclass{scrreprt}

\usepackage[
  includemp,
  showframe,
  reversemp,
  paperwidth=20.1cm,
  paperheight=25.80cm,
  top=2.30cm,
  bottom=3.4cm,
  inner=2.7cm,
  outer=2.7cm,
  marginparwidth=1.6cm, % Fixed for now
  marginparsep=0.4cm
]{geometry}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother

\usepackage{graphicx}
\renewcommand*{\chapterformat}{%
  \raisebox{-\ht\strutbox}[\ht\strutbox][\dp\strutbox]{% move the chapter number down
    \makebox[0pt][r]{%
      \scalebox{2}{% double size the chapter number
        \chapappifchapterprefix{\ }\thechapter\autodot
        \rule[-\dp\strutbox]{1pt}{\baselineskip}% add a rule behind the number
      }%
      \hskip\marginparsep
    }%
  }%
}%
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}

\RedeclareSectionCommand[
  beforeskip=-1sp plus -1sp minus 1sp,% remove the vertical skip before the chapter heading
]{chapter}

\begin{document}

\chapter{test}
\chapter{Test with a longer name, test with a longer name, test with a 
longer name}
\section{test}
\section{test}

\end{document}

第二个建议

尽管如此,通过这两个例子,您应该能够调整结果以满足您自己的要求。

答案2

另一个非常相似的答案(包括那行)。我设置了一个盒子来测量估计所需的高度。

\documentclass{scrreprt}

\usepackage[
    includemp,
    showframe,
    reversemp,
    paperwidth=20.1cm,
    paperheight=25.80cm,
    top=2.30cm,
    bottom=3.4cm,
    inner=2.7cm,
    outer=2.7cm,
    marginparwidth=1.6cm, % Fixed for now
    marginparsep=0.4cm
]{geometry}

\usepackage{graphicx}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother


\renewcommand*{\chapterformat}{%
    \setbox0\vbox{A\\A}%
    \smash{\raisebox{-\baselineskip}{\makebox[0pt][r]{%
        \chapappifchapterprefix{\ }%
        \resizebox{!}{\ht0}{\thechapter\autodot}%
        ~\rule{3pt}{\ht0}\hskip\marginparsep}}}}%
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}

\begin{document}


\chapter{test}
\chapter{Test with a longer name, test with a longer name, test with a 
longer name}
\section{test}
\section{test}


\end{document}

在此处输入图片描述 在此处输入图片描述

答案3

这是一种方法。我认为没有垂直线看起来更好:

\documentclass{scrreprt}

\usepackage[
includemp,
                  showframe,
                  reversemp,
            paperwidth=20.1cm,
            paperheight=25.80cm,
            top=2.30cm,
            bottom=3.4cm,
            inner=2.7cm,
            outer=2.7cm,
            marginparwidth=1.6cm, % Fixed for now
            marginparsep=0.4cm
            ]{geometry}

\makeatletter % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother
\usepackage{lettrine}
\usepackage{graphicx}

\renewcommand*{\chapterformat}{\makebox[0pt][r]{\chapappifchapterprefix{\
}\raisebox{-0.66\height}[0pt][0pt]{\resizebox{!}{1.525\baselineskip}{\thechapter}}\autodot\hskip\marginparsep}}%
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}

\begin{document}

\chapter{test}

\chapter{Test with a longer name, test with a longer name, test with a
longer name}
\section{test}
\section{test}

\end{document} 

在此处输入图片描述 在此处输入图片描述

或者也许使用一些颜色和粗线,使用以下代码:

\renewcommand*{\chapterformat}{\makebox[0pt][r]{\chapappifchapterprefix{\
}\raisebox{-0.66\height}[0pt][0pt]{\resizebox{!}{1.525\baselineskip}{\color{Gainsboro!50!Lavender}\thechapter\hspace{5pt}\vline width 1.5pt}}\autodot\hskip\marginparsep}}%

在此处输入图片描述

相关内容