scrbook без главыheadstartvskip для ненумерованной главы

scrbook без главыheadstartvskip для ненумерованной главы

Я пишу документ с использованием scrbookкласса KOMA-Script. Я использую пользовательский стиль главы и \chapterheadstartvskip. Номер главы печатается как tikzналожение в результирующем пробеле. Для ненумерованных глав (Содержание, Библиография) это приводит к большому пустому пробелу, который я хочу устранить.

Я пробовал установить \chapterheadstartvskipзначение 0 и добавить \vspaceв начало моего переопределения \chapterformat, но, \vspaceпохоже, это не дало никакого эффекта.

Есть ли способ сделать так, чтобы \chapterheadstartvskipнумерованные и ненумерованные главы были разными?

МВЭ:

\documentclass[BCOR=15mm, DIV=8]{scrbook}

\KOMAoptions{
    headings=twolinechapter,
    chapterprefix=false,
    numbers=noenddot
}

\usepackage{typearea}
\usepackage[utf8]{inputenc}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{lipsum}
\usepackage{filecontents}
\usepackage[
    backend=biber,
    style=numeric-comp,
    sorting=none,
    doi=false,
    url=false,
    isbn=false,
    maxbibnames=99,
    maxcitenames=99,
    giveninits=true,
    backref=true
]{biblatex}

\usepackage{tikz}
\usetikzlibrary{
    calc,
    positioning}
\tikzset{>=latex}
\usepackage{tikzpagenodes}

\usepackage{etoolbox}
\usepackage{xstring}
\usepackage{calc}

\definecolor{laccentcolor}{HTML}{d3d3d3}

\addtokomafont{disposition}{\rmfamily}

\addtokomafont{chapter}{\scshape\LARGE}

\newif\ifappendix

\def\chaplengths{{11mm,6mm,7mm,2.5mm,7mm,5mm,6mm,7mm,6.5mm}}
\def\applengths{{4mm,8.5mm,6mm}}
\renewcommand*{\chapterformat}{%
\begin{tikzpicture}[remember picture]
\coordinate (mychapanchor-\arabic{chapter});
\end{tikzpicture}
\begin{tikzpicture}[remember picture, overlay]
    \pgfmathsetmacro{\mylength}{\ifappendix\applengths[\arabic{chapter}-1]\else\chaplengths[\arabic{chapter}-1]\fi}
    \node[anchor=south east,xshift=\mylength,
          inner sep=0, outer sep=0]
          at ([yshift=1.2cm]mychapanchor-\arabic{chapter}-| current page text area.east){%
        \fontsize{10cm}{10cm}\selectfont%
        \textcolor{laccentcolor}{\thechapter}%
    };
    % alignment line
    % \draw[thin] (current page text area.north east)
    %     -- (current page text area.south east);
\end{tikzpicture}%
}
\renewcommand*{\chapterheadstartvskip}{\vspace*{9cm}}

\begin{filecontents}{bibliography.bib}
@article{cava1987oxygen,
  title={Oxygen stoichiometry, superconductivity and normal-state
         properties of YBa2Cu3O7--$\delta$},
  author={Cava, RJ and Batlogg, B. and Chen, CH and Rietman, EA and
          Zahurak, SM and Werder, D.},
  journal={Nature},
  volume={329},
  number={6138},
  pages={423--425},
  year={1987},
  publisher={Nature Publishing Group}
}

@book{sterner2002ecological,
  title={Ecological stoichiometry: the biology of elements from
         molecules to the biosphere},
  author={Sterner, R.W. and Elser, J.J.},
  year={2002},
  publisher={Princeton Univ Pr}
}

@article{castro1975cortazar,
  title={Cort{\'a}zar, Surrealism, and Pataphysics},
  author={Castro-Klaren, S.},
  journal={Comparative Literature},
  volume={27},
  number={3},
  pages={218--236},
  year={1975},
  publisher={JSTOR}
}

@inproceedings{munro1992deterministic,
  title={Deterministic skip lists},
  author={Munro, J.I. and Papadakis, T. and Sedgewick, R.},
  booktitle={Proceedings of the third annual ACM-SIAM symposium on
             Discrete algorithms},
  pages={367--375},
  year={1992},
  organization={Society for Industrial and Applied Mathematics}
}

@book{Jones-2002,
   author = {Jones, Christopher A. and Drake, Fred L.},
   title = {Python and XML},
   publisher = {O'Reilly},
   address = {Sebastopol, Calif.},
   edition = {1st},
   keywords = {Python (Computer program language)
XML (Document markup language)},
   pages = {xvi, 360 p.},
   year = {2002}
}
\end{filecontents}

\addbibresource{bibliography.bib}

\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{A Fancy Chapter Name to Test the Formatting}
\lipsum[1]

\appendix\appendixtrue

\chapter{A Fancy Chapter Name to Test the Formatting}
\lipsum[1]

\backmatter

\nocite{*}
\printbibliography[heading=bibintoc]

\end{document}

решение1

Как отметил @Schweinebacke в комментарии: Основная проблема — это скрытая высота \chapterformat. Кроме того, вам не нужен пакет tikzpagenodesи все remember pictureтакое.

Удалите chapterprefix=falseи используйте headings=twolinechapterили chapterprefix=true.

\documentclass[BCOR=15mm, DIV=8]{scrbook}
\KOMAoptions{
    headings=twolinechapter,
    numbers=noenddot
}
%\usepackage[utf8]{inputenc}% not needed with an uptodate TeX distribution
\usepackage{kpfonts}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{lipsum}

\usepackage{tikz}
\definecolor{laccentcolor}{HTML}{d3d3d3}

\addtokomafont{disposition}{\rmfamily}
\addtokomafont{chapter}{\scshape\LARGE}

\newif\ifappendix

\def\chaplengths{{11mm,6mm,7mm,2.5mm,7mm,5mm,6mm,7mm,6.5mm}}
\def\applengths{{4mm,8.5mm,6mm}}
\renewcommand*{\chapterformat}{%
  \hfill\begin{tikzpicture}
    \pgfmathsetmacro{\mylength}{\ifappendix\applengths[\arabic{chapter}-1]\else\chaplengths[\arabic{chapter}-1]\fi}
    \node(n)[inner sep=0, outer sep=0,
        font=\fontsize{10cm}{10cm}\selectfont,
        text=laccentcolor
      ]{\rule{0pt}{\ht\strutbox}\thechapter};
    \pgfresetboundingbox
    \useasboundingbox(n.south west)rectangle([xshift=-\mylength]n.north east);% bounding box with a fixed height
\end{tikzpicture}%
}


\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{A Fancy Chapter Name to Test the Formatting}
\lipsum[1]
\appendix\appendixtrue
\chapter{A Fancy Chapter Name to Test the Formatting}
\lipsum[1]
\end{document}

Результат:

введите описание изображения здесь

Дополнительные замечания: Не загружайте package typeareaвручную в свой код. Класс KOMA-Script делает это автоматически. Option chapterprefix=falseделает то же самое, что headings=onlinechapterи , поэтому перезаписывает headings=twolinechapter. Поэтому вам придется удалить эту опцию.

Вертикальное пространство над заголовком главы и между номером и заголовком можно настроить по своему усмотрению с помощью опций beforeskipи , innerskipнапример \RedeclareSectionCommand:

\RedeclareSectionCommand[
  beforeskip=0pt,
  afterindent=true,
  innerskip=\baselineskip
]{chapter}

Обновлять

Предложение для \chapterformatбез tikzpicture:

\def\chaplengths{{11mm,6mm,7mm,2.5mm,7mm,5mm,6mm,7mm,6.5mm}}
\def\applengths{{4mm,8.5mm,6mm}}
\renewcommand*{\chapterformat}{%
  \pgfmathsetmacro{\mylength}{\ifappendix\applengths[\arabic{chapter}-1]\else\chaplengths[\arabic{chapter}-1]\fi}%
  \hfill
  \makebox[\dimexpr\width-\mylength pt\relax][l]{%
    \fontsize{10cm}{10cm}\selectfont
    \rule{0pt}{\ht\strutbox}%
    \textcolor{laccentcolor}{\thechapter}%
  }%
}

Связанный контент