正如所述本文,我正在尝试复制一张 CD。按照那里给出的解决方案,我使用scrlayer
来格式化通过 显示的章节标题\leftmark
。现在,CD 手册指出章节标题应左对齐且不带连字符。但放入\raggedright
图层定义没有任何效果。有办法实现这一点吗?
梅威瑟:
\documentclass[%
openany
]{scrbook}
\usepackage[%
a4paper
,inner=26mm
,outer=7mm
,top=81.5mm
,bottom=31.5mm
,headheight=32pt
,headsep=54mm
,showframe
]{geometry}
\usepackage{lipsum}
\usepackage{scrlayer}
\DeclareNewLayer[
foreground,
oddpage,
area={26mm}{\dimexpr14mm\relax}{\textwidth}{32pt},
contents={\vfill\hfill\pagemark}
]{hc.head.odd}
\DeclareNewLayer[
clone=hc.head.odd,
evenpage,
hoffset=7mm,
contents={\vfill\pagemark}
]{hc.head.even}
\DeclareNewLayer[
foreground
,headsep
,addvoffset=-3mm
,contents={\vfill\rule[-\dp\strutbox]{\layerwidth}{3pt}}
]{hc.headsep.bottom.line}
\DeclareNewLayer[
foreground,
,footskip,
,contents={\vfill\rule[-\dp\strutbox]{\layerwidth}{.5pt}}
]{hc.footskip.bottom.line}
\DeclareNewLayer[
clone=hc.headsep.bottom.line,
,addvoffset=-1mm
,contents={\vfill{\strut\usekomafont{chapter}\raggedright\leftmark\nobreak\strut}}
]{hc.headsep}
\DeclareNewPageStyleByLayers{plain.hc}{%
hc.head.odd,hc.head.even,%
hc.headsep.bottom.line,%
hc.footskip.bottom.line%
}
\DeclareNewPageStyleByLayers{chapterpage.hc}{%
hc.head.odd,hc.head.even,%
hc.headsep,%
hc.headsep.bottom.line,%
hc.footskip.bottom.line%
}
\DeclarePageStyleAlias{plain}{plain.hc}
\DeclarePageStyleAlias{chapterpage}{chapterpage.hc}
\pagestyle{plain}
\setkomafont{chapter}{\normalfont\fontsize{32pt}{30.5pt}\selectfont}
\setkomafont{pagenumber}{\bfseries\fontsize{32pt}{30.5pt}\selectfont}
\makeatletter
\newcommand*\headchapter{\@ifstar{\@sheadchapter}{\@headchapter}}
\newcommand*\@headchapter[1]{%
\clearpage\thispagestyle{chapterpage}\refstepcounter{chapter}%
\markleft{\thechapter\enskip#1}%
\addchaptertocentry{\thechapter}{#1}%
}
\newcommand*\@sheadchapter[1]{%
\clearpage\thispagestyle{chapterpage}%
\markleft{#1}%
}
\newcommand\addheadchap[1]{%
\clearpage\thispagestyle{chapterpage}%
\markleft{#1}%
\addchaptertocentry{}{#1}%
}
\makeatother
\deftocheading{toc}{\headchapter*{\contentsname}}
\begin{document}
\addheadchap{Test texttexttext texttexttext texttexttext texttexttext}
\lipsum
\end{document}
答案1
如果你想使用\raggedchapter
- 它被预定义为\raggedright
使用\parbox
contents={\vfill\parbox{\layerwidth}{\raggedchapter\usekomafont{chapter}\leftmark\strut}}
\documentclass[%
openany
]{scrbook}
\usepackage[%
a4paper
,inner=26mm
,outer=7mm
,top=81.5mm
,bottom=31.5mm
,headheight=32pt
,headsep=54mm
,showframe
]{geometry}
\usepackage{lipsum}
\usepackage{scrlayer}
\DeclareNewLayer[
foreground,
oddpage,
area={26mm}{\dimexpr14mm\relax}{\textwidth}{32pt},
contents={\vfill\hfill\pagemark}
]{hc.head.odd}
\DeclareNewLayer[
clone=hc.head.odd,
evenpage,
hoffset=7mm,
contents={\vfill\pagemark}
]{hc.head.even}
\DeclareNewLayer[
foreground
,headsep
,addvoffset=-3mm
,contents={\vfill\rule[-\dp\strutbox]{\layerwidth}{3pt}}
]{hc.headsep.bottom.line}
\DeclareNewLayer[
foreground,
,footskip,
,contents={\vfill\rule[-\dp\strutbox]{\layerwidth}{.5pt}}
]{hc.footskip.bottom.line}
\DeclareNewLayer[
clone=hc.headsep.bottom.line,
,addvoffset=-1mm,
,contents={\vfill\parbox{\layerwidth}{%
\raggedchapter\usekomafont{chapter}\leftmark\strut}}
]{hc.headsep}
\DeclareNewPageStyleByLayers{plain.hc}{%
hc.head.odd,hc.head.even,%
hc.headsep.bottom.line,%
hc.footskip.bottom.line%
}
\DeclareNewPageStyleByLayers{chapterpage.hc}{%
hc.head.odd,hc.head.even,%
hc.headsep,%
hc.headsep.bottom.line,%
hc.footskip.bottom.line%
}
\DeclarePageStyleAlias{plain}{plain.hc}
\DeclarePageStyleAlias{chapterpage}{chapterpage.hc}
\pagestyle{plain}
\setkomafont{chapter}{\normalfont\fontsize{32pt}{30.5pt}\selectfont}
\setkomafont{pagenumber}{\bfseries\fontsize{32pt}{30.5pt}\selectfont}
\makeatletter
\newcommand*\headchapter{\@ifstar{\@sheadchapter}{\@headchapter}}
\newcommand*\@headchapter[1]{%
\clearpage\thispagestyle{chapterpage}\refstepcounter{chapter}%
\markleft{\thechapter\enskip#1}%
\addchaptertocentry{\thechapter}{#1}%
}
\newcommand*\@sheadchapter[1]{%
\clearpage\thispagestyle{chapterpage}%
\markleft{#1}%
}
\newcommand\addheadchap[1]{%
\clearpage\thispagestyle{chapterpage}%
\markleft{#1}%
\addchaptertocentry{}{#1}%
}
\makeatother
\deftocheading{toc}{\headchapter*{\contentsname}}
\begin{document}
\addheadchap{Test texttexttext texttexttext texttexttext texttexttext}
\lipsum
\end{document}