删除章节内容前的空白

删除章节内容前的空白

我正在努力用 (Lua)LaTeX 复制企业设计。问题出在对页眉(和边距)进行非常特殊的处理上:

页眉非常大,顶部外角有页码,底部有一行。只有带有章节标题的页面才应在空白处设置章节标题。我已经使用 TikZ 解决了这个问题(以下http://texblog.net/latex-archive/uncategorized/fancy-chapter-tikz/)。但是,我无法删除章节标题后的文本块开头的空白。

需要删除的空间

我已经尝试过了\titlespacing{\chapter}{0pt}{0pt}{0pt}\RedeclareSectionCommand[afterskip=0pt,beforeskip=0pt]{chapter}但是\renewcommand{\chapterheadendvskip}{0pt}都没有达到我期望的效果。

梅威瑟:

\documentclass[%
  openany
  ,a4paper
  ,footsepline=0.5pt
  ,headings=small
  ]{scrbook}
\usepackage{scrlayer-scrpage}

\usepackage[%
  a4paper
  ,inner=26mm
  ,outer=7mm
  ,top=81.5mm
  ,bottom=31.5mm
  ,headheight=32pt
  ,headsep=54mm
  ,showframe
  ]{geometry}

\usepackage{lipsum}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{calc,positioning}
\usepackage{tikzpagenodes}
\usepackage[explicit]{titlesec}

\titlespacing{\chapter}{0pt}{0pt}{0pt}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \fontsize{32pt}{30.5pt}}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}{%
    \begin{tikzpicture}[remember picture,overlay, every node/.style={inner sep=0,outer sep=0, anchor=base, baseline}]
      \coordinate (chapter) at ($(current page text area.north west)+    (0,7mm)$);
      \node[above right, text width=\textwidth] at (chapter) {\chapterlabel #1};
\end{tikzpicture}
  }

%\RedeclareSectionCommand[afterskip=0pt,beforeskip=0pt]{chapter}
%\renewcommand{\chapterheadendvskip}{0pt}

\clearscrheadfoot
\ohead{\pagemark} 
\chead{%
  \begin{tikzpicture}[remember picture,overlay, every node/.style={inner sep=0,outer sep=0}]
    \coordinate (hsepline) at ($(current page text area.north west)+(0,+3.5mm)$);
    \draw [line width = 3pt] (hsepline) -- +(\textwidth,0);
  \end{tikzpicture}
}
\renewcommand{\chapterpagestyle}{scrheadings}

\title{Title}
\author{Me}
\date{2015}
\begin{document}
\maketitle
\begin{multicols}{2}[\chapter{A very very very very long chapter title spanning two lines}]
\lipsum[4]
\end{multicols}
\begin{multicols}{2}[\chapter{Chapter}]
\lipsum
\end{multicols}
\clearpage
\thispagestyle{empty}
Back matter
\end{document}

编辑: 使用 时\titlespacing{\chapter}{0pt}{-10mm}{0pt},单行章节标题的行为符合预期,但标题跨越两行的章节仍会显示间隙。但是,使用 时,\titlespacing{\chapter}{0pt}{-10mm}{-10mm}长标题的间隙会消失,而单行章节标题的文本会向上移动太多: 空间太小

答案1

scrlayer-scrpage

请注意,不建议与 KOMA-Script 类一起使用titlesec。建议使用定义新的页面样式来插入章节标题

在此处输入图片描述

\documentclass[%
   openany
  ,a4paper
  ,headings=small
  ]{scrbook}
\usepackage[%
  a4paper
  ,inner=26mm
  ,outer=7mm
  ,top=81.5mm
  ,bottom=31.5mm
  ,headheight=32pt
  ,headsep=54mm
  ,showframe
  ]{geometry}
\usepackage{lipsum}
\usepackage{multicol}

\usepackage[footsepline=.5pt,manualmark]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead*{\pagemark}

\ModifyLayer[foreground]{scrheadings.head.odd}
\ModifyLayer[foreground]{scrheadings.head.even}
\ModifyLayer[foreground]{plain.scrheadings.head.odd}
\ModifyLayer[foreground]{plain.scrheadings.head.even}

\DeclareNewLayer[
  foreground
  ,headsep
  ,addvoffset=-3mm
  ,contents={\vfill\rule[-\dp\strutbox]{\layerwidth}{3pt}}
]{hc.headsep.bottom.line}
\DeclareNewLayer[
  clone=hc.headsep.bottom.line,
  ,addvoffset=-4mm
  ,contents={\vfill{\usekomafont{chapter}\leftmark}}
]{hc.headsep}
\AddLayersToPageStyle{scrheadings}{hc.headsep.bottom.line}

\DeclareNewPageStyleByLayers{chapterpage}{}
\ForEachLayerOfPageStyle{scrheadings}{\AddLayersToPageStyle{chapterpage}{#1}}
\AddLayersToPageStyle{chapterpage}{hc.headsep}

\setkomafont{chapter}{\normalfont\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}}

\title{Title}
\author{Me}
\date{2015}
\begin{document}
\maketitle
\tableofcontents
\begin{multicols}{2}[\headchapter{Chapter One}]
\lipsum[4]
\end{multicols}
\begin{multicols}{2}[\headchapter{A very very very very long chapter title spanning two lines}]
\lipsum[4]
\end{multicols}
\headchapter{Chapter Three}
\begin{multicols}{2}
\lipsum\lipsum
\end{multicols}
%
\addheadchap{Test}
\lipsum
\clearpage
\thispagestyle{empty}
Back matter
\end{document}

屏幕层

scrlayer以下是仅使用Instead 的附加建议scrlayer-scrpage

代码:

\documentclass[%
   openany
  ,a4paper
  ,headings=small
  ]{scrbook}
\usepackage[%
  a4paper
  ,inner=26mm
  ,outer=7mm
  ,top=81.5mm
  ,bottom=31.5mm
  ,headheight=32pt
  ,headsep=54mm
  ,showframe
  ]{geometry}
\usepackage{lipsum}
\usepackage{multicol}

\usepackage{scrlayer}
\DeclareNewLayer[
  foreground,
  oddpage,
  area={26mm}{\dimexpr81.5mm-32pt-54mm\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=-4mm
  ,contents={\vfill{\usekomafont{chapter}\leftmark}}
]{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}

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

\title{Title}
\author{Me}
\date{2015}
\begin{document}
\maketitle
\tableofcontents
\begin{multicols}{2}[\headchapter{Chapter One}]
\lipsum[4]
\end{multicols}
\begin{multicols}{2}[\headchapter{A very very very very long chapter title spanning two lines}]
\lipsum[4]
\end{multicols}
\headchapter{Chapter Three}
\begin{multicols}{2}
\lipsum\lipsum
\end{multicols}
%
\addheadchap{Test}
\lipsum
\clearpage
\thispagestyle{empty}
Back matter
\end{document}

结果和上面一样。

相关内容