0

I am trying to restyle my chapter headings. I want the chapter number to strecht vertically over two lines. In this way for long chapter names, the number is before the whole name. Furthermore I would like to add a vertical line between the number and chapter name. I tried and searched some examples on the forum but not really succeed.

Does somebody have any idea??

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

enter image description here

3
  • I do not really understand what you want: \usepackage{graphicx} \renewcommand*{\chapterformat}{\makebox[0pt][r]{\scalebox{2}{\chapappifchapterprefix{\ }\thechapter\autodot\rule{1pt}{\ht\strutbox}}\hskip\marginparsep}} or \usepackage{graphicx} \renewcommand*{\chapterformat}{\raisebox{-\ht\strutbox}[\ht\strutbox][\dp\strutbox]{\makebox[0pt][r]{\scalebox{2}{\chapappifchapterprefix{\ }\thechapter\autodot\rule[-\dp\strutbox]{1pt}{\baselineskip}}}}\hskip\marginparsep}? Aug 24, 2017 at 12:21
  • If add \usepackage{graphixs} and the code its displays \chapappifchapterprefix and the marginparsep comments with white letters and it doesnt work. So I dont know
    – SLeenders
    Aug 24, 2017 at 12:30
  • TeX.SX often adds invisible spaces to inline code in comments. So copy and paste sometimes does not work. I've added an answer. Nevertheless, it would help, if you make your question more clear and, e.g., add an image of the wanted result not only of the result you currently get. Aug 24, 2017 at 12:43

3 Answers 3

0

I do not really understand, what you want. Maybe you want:

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

first suggestion

or

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

second suggestion

Nevertheless, with those two examples you should be able to adapt the result to fit your own requirements.

5
  • Sorry to bother you with another thing. But for the single lined chapter I tried to center the ''test'' with the 1 and the vertical line. Is there a command which I can add to \raisebox, so the chapter name is in the middle of the number and vertical line for both cases?
    – SLeenders
    Aug 24, 2017 at 13:20
  • I'm not sure, that I understand your request. You can change the raise value (e.g. -.5\ht\strutbox instead of -\ht\strutbox). But then the multi-line-heading will start in the middle of the number, too. If you want different alignment depending on the height of the text, you need to redefine \chapterlinesformat instead of only \chapterformat. Once again: Please edit your question to make it more precise. Aug 25, 2017 at 13:40
  • I sure want to edit my question if needed. But what you describe is exactly what i meant. I never made my own chapter heading so I dont really know how to define the /chapterlinesformat. Would be great if you can help with that last part?
    – SLeenders
    Aug 27, 2017 at 13:33
  • @SLeenders Which last part? Please describe exactly what you want in your question or ask a following up question that make clear what you want different from the given solutions. And don't forget the case of more than two lines of headings text. If I tell you, you can either do this or that with different results and you tell me only, that this is exactly what you want, this does not really help. A question should be self descriptive without the need to read comments to the question or even to answers. Aug 27, 2017 at 16:59
  • Okay, I posted a new question ''chapter heading styles''.
    – SLeenders
    Aug 28, 2017 at 8:12
1

Another quite similar answer (including the line). I set up a box to measure the estimated needed height.

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

enter image description here enter image description here

1

Here is a way. I think it looks better without a vertical rule:

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

enter image description here enter image description here

Or maybe with some colour and a thick rule, with this code:

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

enter image description here

You must log in to answer this question.

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