Page Layout ⇒ Place chapter/section in left/right margin instead of top margin
Place chapter/section in left/right margin instead of top margin
I agreed with a publisher to write my book in LaTeX and they sent me a number of different styles from which I picked one and which I am trying to replicate. The one that I have chosen does not indicate the chapter and section in the header but in the left and right margin as vertical text. To illustrate this, I attached a sample.
I am wondering if a package exists that does this and ion somebody can help me. Thanks!
- Attachments
-
- sample.pdf
- (43.6 KiB) Downloaded 296 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Place chapter/section in left/right margin instead of top margin
First, I redefine how the chapters and sections are presented:
\renewcommand{\chaptermark}[1]%
{\markboth{{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]%
{\markright{{\thesection.\ #1}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\newcommand{\helv}{%
\fontfamily{put}\fontsize{10}{11}\selectfont}
Then I define the following two boxes (one for the chapter, another for the section) which can then be used with fancy headers by using \fancyhead[LE]{\marginchapter} and \fancyfoot[RO]{\marginsection}:
\newcommand{\marginchapter}{%
\makebox[0em][r]{% make the box extend into margin
\raisebox{0ex}[0ex][0ex]{% make the box have 0 hgt and dpth
\rotatebox[origin=rB]{90}{% rotate it
\colorbox{white}{\color{gray}\leftmark \ \ \color{black}\thepage}}}%
\hspace*{2em}% how far, horiz, box is from leftmargin
}}
\newcommand{\marginsection}{%
\makebox[0em][r]{% make the box extend into margin
\raisebox{0ex}[0ex][0ex]{% make the box have 0 hgt and dpth
\rotatebox[origin=rB]{-90}{% rotate it
\colorbox{white}{\color{gray}\rightmark \ \ \color{black}\thepage}}}%
\hspace*{-3em}% how far, horiz, box is from leftmargin
}}
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Place chapter/section in left/right margin instead of top margin
Code: Select all
\documentclass{scrbook}\usepackage{graphicx}\usepackage{scrlayer}\usepackage{blindtext}\automark[chapter]{chapter}\DeclareLayer[background,evenpage,textarea,addhoffset=-\marginparsep-\baselineskip,width=\baselineskip,contents={\sffamily\rotatebox[origin=r]{90}{\leftmark\quad\pagemark}}]{evenpagemark}\DeclareLayer[background,oddpage,textarea,addhoffset=\textwidth+\marginparsep,width=\baselineskip,contents={\sffamily\rotatebox[origin=l]{270}{\makebox[\textheight][r]{\leftmark\quad\pagemark\enskip}}}]{oddpagemark}\DeclarePageStyleByLayers{sidemarks}{evenpagemark,oddpagemark}\renewcommand*{\chapterpagestyle}{sidemarks}% Use the new page style also for chapter pages.\renewcommand*{\chaptermarkformat}{}% Don't show chapter number in the marks\setkomafont{pagenumber}{\bfseries}\pagestyle{sidemarks}\begin{document}\tableofcontents\blinddocument\end{document}

scrlayer
. Usually it is used via scrlayer-scrpage
. But the example above shows, that it also can be used directly to define your own layer page style(s).You can use the package also with a standard class. But the standard class book always uses page style
plain
for the chapter start page. So if you want to use the new pagestyle sidemarks
also for the chapter start page (as shown above) you have to redefine pagestyle plain
too:
Code: Select all
\documentclass{book}\usepackage{graphicx}\usepackage[markcase=noupper]{scrlayer}\usepackage{blindtext}\automark[chapter]{chapter}\DeclareLayer[background,evenpage,textarea,addhoffset=-\marginparsep-\baselineskip,width=\baselineskip,contents={\sffamily\rotatebox[origin=r]{90}{\leftmark\quad\pagemark}}]{evenpagemark}\DeclareLayer[background,oddpage,textarea,addhoffset=\textwidth+\marginparsep,width=\baselineskip,contents={\sffamily\rotatebox[origin=l]{270}{\makebox[\textheight][r]{\leftmark\quad\pagemark\enskip}}}]{oddpagemark}\DeclarePageStyleByLayers{sidemarks}{evenpagemark,oddpagemark}\DeclarePageStyleAlias{plain}{sidemarks}% Make pagestyle plain be the same like pagestyle sidemarks\renewcommand*{\chaptermarkformat}{}% Don't show chapter number in the marks\setkomafont{pagenumber}{\bfseries}\pagestyle{sidemarks}\begin{document}\tableofcontents\blinddocument\end{document}
sidemarks
page. So maybe you need to define a new plain pagestyle named, e.g., realplain
. Because of easy configuration of things like \chapterpagestyle
I like the KOMA-Script classes more.