Komascript 章节标题位置

Komascript 章节标题位置

我正在尝试使用 Tikz 格式化章节标题(我使用的是具有 komascript 3.12 的 Ubuntu)以添加minitoc。我可以格式化数字和章节前缀,但章节标题不会改变位置,我想将其放在顶部。要添加 minitoc,我认为我必须将其添加到代码的 tikz 部分。

以下是我目前得到的信息:

\documentclass{scrbook}

\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{lipsum}
\definecolor{back}{HTML}{141414}
\definecolor{fore}{HTML}{FC4508}

\newcommand*\chapterimageheight{.2\paperheight}% height of the chapter images
\newcommand*\chapterhalfimageheight{.1\paperheight}% height of the chapter images

\usepackage{tikz}
\usetikzlibrary{positioning, backgrounds}
\usepackage{tikzpagenodes}

\renewcommand\chapterformat{%
  %\hspace*{-1in} %customize this to your needs
  \begin{tikzpicture}[remember picture, overlay]
        \fill[back] 
        ([yshift=-\chapterimageheight] current page.north west) 
        rectangle (current page.north east);%
%
        \node[anchor=center] at ([yshift=-1cm, xshift=-2cm] current page.north east) %
            {\color{white} \chapapp};
%
        \node[anchor=center] at ([yshift=-3.7cm, xshift=-2cm] current page.north east) %
            {\color{fore} {\rmfamily \fontsize{120}{120} \selectfont\thechapter}};
  \end{tikzpicture}
}

\usepackage{etoolbox}
\appto\chapterheadstartvskip{\noindent\vspace*{2cm}}


\begin{document}

\chapter{Introduction}  
\lipsum[2]
\section{My Section}

$$
\int f(x) dx = \frac{\partial g}{\partial y}
$$

\end{document}

答案1

我不太明白你想做什么,而且 3.12 版本真的很旧。我测试的最旧版本是 3.16,CTAN 上的当前版本是 3.19a。但你必须更改字体元素chapter才能使其在黑色背景上可见。要将其向上移动,请使用负值\vspace*

\documentclass{scrbook}
\usepackage{lmodern}% <- added
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{lipsum}
\definecolor{back}{HTML}{141414}
\definecolor{fore}{HTML}{FC4508}

\newcommand*\chapterimageheight{.2\paperheight}% height of the chapter images
\newcommand*\chapterhalfimageheight{.1\paperheight}% height of the chapter images

\usepackage{tikz}
\usetikzlibrary{positioning, backgrounds}
\usepackage{tikzpagenodes}

\renewcommand\chapterformat{%
  %\hspace*{-1in} %customize this to your needs
  \begin{tikzpicture}[remember picture, overlay]
        \fill[back] 
        ([yshift=-\chapterimageheight] current page.north west) 
        rectangle (current page.north east);%
%
        \node[anchor=center] at ([yshift=-1cm, xshift=-2cm] current page.north east) %
            {\color{white} \chapapp};
%
        \node[anchor=center] at ([yshift=-3.7cm, xshift=-2cm] current page.north east) %
            {\color{fore} {\rmfamily \fontsize{120}{120} \selectfont\thechapter}};
  \end{tikzpicture}%
}

\renewcommand\chapterheadstartvskip{%
  \vspace*{\dimexpr-1in-\headsep-\headheight-\topmargin-\topskip+.75cm\relax}}
\usepackage{etoolbox}
\appto\chapterheadendvskip{%
  \vspace{\dimexpr 1in+\headsep+\headheight+\topmargin+\topskip+2cm\relax}}

\addtokomafont{chapter}{\color{white}}

\begin{document}
\chapter{Introduction}  
\lipsum[2]
\section{My Section}
\[
  \int f(x) dx = \frac{\partial}{\partial y}
\]
Used version: \KOMAScriptVersion
\end{document}

结果:

在此处输入图片描述

相关内容