我在章节标题中使用了一种相当花哨的风格,即
\documentclass[12pt,open=left]{scrbook}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{scrpage2}\pagestyle{scrheadings}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{}}
\titleformat{\chapter}
[hang]
{}
{}
{0em}
{\Large \bf
\ifnum\value{chapter}>0
\begin{tikzpicture}
\node[text width=2.55cm] (chapter) at (0,0) {Ch \thechapter \newline \newline};
\draw [ultra thick] (chapter.north east) -- (chapter.south east);
\end{tikzpicture}\hspace{0.5cm}
\fi
\Huge}
[\ifnum\value{chapter}>0
\normalsize \vspace{-1.3cm} \hspace{2.85cm}
\tikz{
\node[text width=10cm] (toc) at (0,0){
\newline \newline \newline
%\parindent=20em
\begin{minipage}{12cm}
%\parindent=20em
\printcontents[c]{}{1}{}
\end{minipage}
};
\draw [ultra thick] (toc.north west) -- (toc.south west);}
\fi]
\usepackage{minitoc}
\begin{document}
\startcontents[c]
\chapter{Short chapter title}
\section{thats an arbitrary section}
\subsection{thats an arbitrary section}
\subsection{thats an arbitrary section}
\section{thats an arbitrary section}
\section{thats an arbitrary section}
\stopcontents[c]
\startcontents[c]
\chapter{Here appears a very long chapter title causing issues}
\section{thats an arbitrary section}
\subsection{thats an arbitrary section}
\subsection{thats an arbitrary section}
\section{thats an arbitrary section}
\section{thats an arbitrary section}
\stopcontents[c]
\end{document}
不幸的是,如果标题超过 2 行,我的风格就会被破坏。我希望标题的第二行与第一行从相同的位置开始,并且黑线没有间隙。
最简单的解决方案似乎是将标题限制在 tikz 节点中,一侧为黑色,但到目前为止我还没有找到可行的解决方案。
答案1
您需要explicit
包选项,它可以让您指定文本的打印位置。
启用该选项后,您可以获得类似的效果:
\node [right,text width=12cm] at(chapter.south east){#1};
进入您的tikzpicture
,其中#1
设置文本位置。
梅威瑟:
\documentclass[12pt,open=left]{scrbook}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{scrpage2}\pagestyle{scrheadings}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{}}
\titleformat{\chapter}
[hang]
{}
{}
{0em}
{\Large \bf
\ifnum\value{chapter}>0
\begin{tikzpicture}
\node[text width=2.55cm] (chapter) at (0,0) {Ch \thechapter \newline \newline};
\draw [ultra thick] (chapter.north east) -- (chapter.south east);
\node [right,text width=12cm] at(chapter.south east){#1};
\end{tikzpicture}\hspace{0.5cm}
\fi
\Huge}
[\ifnum\value{chapter}>0
\normalsize \vspace{-1.3cm} \hspace{2.85cm}
\tikz{
\node[text width=10cm] (toc) at (0,0){
\newline \newline \newline
%\parindent=20em
\begin{minipage}{12cm}
%\parindent=20em
\printcontents[c]{}{1}{}
\end{minipage}
};
\draw [ultra thick] (toc.north west) -- (toc.south west);}
\fi]
\usepackage{minitoc}
\begin{document}
\startcontents[c]
\chapter{Short chapter title}
\section{thats an arbitrary section}
\subsection{thats an arbitrary section}
\subsection{thats an arbitrary section}
\section{thats an arbitrary section}
\section{thats an arbitrary section}
\stopcontents[c]
\startcontents[c]
\chapter{Here appears a very long chapter title causing issues}
\section{thats an arbitrary section}
\subsection{thats an arbitrary section}
\subsection{thats an arbitrary section}
\section{thats an arbitrary section}
\section{thats an arbitrary section}
\stopcontents[c]
\end{document}
前:
后:
您可以通过新的节点选项调整文本样式。