根据页面选择columnsep

根据页面选择columnsep

我希望我可以为该页面设置不同的列分隔符(如果它是章节的标题页)。到目前为止,我尝试使用条件语句,ifchapterpage其中的代码makeatother位于这里(作者:@Skillmon)但它无法识别我设置的条件,因此没有任何变化。我如何更改仅包含章节标题的页面的 columnsep?我正在用 编译它LuaLaTeX

\documentclass[11pt,a5paper,twocolumn,twoside]{book}

\usepackage{geometry}
    \geometry{
        paper = a5paper,
        layout = a5paper,
        layoutsize = {148 mm, 210 mm},
        includehead = true,
        includefoot = true,
        inner = 1.5 cm,
        outer = 1 cm,
        top = 1.5 cm,
        bottom = 1.5 cm,
        columnsep = .8cm,
    }


\usepackage{tikz}

\newif\ifchapterpage

\usepackage{etoolbox}
    \makeatletter
    \ifchapterpage%
        \patchcmd\@outputdblcol
        {\normalcolor\vrule\@width\columnseprule}
        {\raisebox{.5\textheight}{%
            \begin{tikzpicture}
                \useasboundingbox;
                \fill[blue] (0,0) circle (.1cm);
                \draw[blue] ++(90:.75) to ++(90:2);
                \draw[blue] ++(-90:.75) to ++(-90:6);
            \end{tikzpicture}}}
        {}{}
    \else%
        \patchcmd\@outputdblcol
        {\normalcolor\vrule\@width\columnseprule}
        {\raisebox{.5\textheight}{%
            \begin{tikzpicture}
                \useasboundingbox;
                \fill[blue] (0,0) circle (.1cm);
                \draw[blue] ++(90:.75) to ++(90:6);
                \draw[blue] ++(-90:.75) to ++(-90:6);
            \end{tikzpicture}}}
        {}{}
    \makeatother
    \fi

\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyhead[L]{\rightmark}
    \fancyhead[C]{\thepage}
    \fancyhead[R]{\chaptername}
    \fancyfoot{}

\usepackage{titlesec}
    \titleformat{\chapter}% command
        [block]% shape
        {\centering\itshape\huge}% format
        {}% label
        {0cm}% sep
        {{\normalsize The tale of\\}}% before-code
        [\chapterpagetrue\vspace{1cm}]% after-code
    \titlespacing{\chapter}% command
        {0pt}% left margin
        {0pt}% Vertical space before title
        {1cm}% Vertical space between title and text

\usepackage{lipsum}


\begin{document}

    \chapter*{Rhotingger}

    \lipsum[1-20]

\end{document}

答案1

你在开始时告诉 TeX,如果这不是章节页面,它应该@outputdblcol以一种方式修补命令,否则以另一种方式修补。然而,在序言中,这不是章节页面。你需要让 TeX 检查每一页。为此,我进入了\ifchapterpageTiZ 图片。另外,您永远不会将条件设置为 false。我也添加了此重置。最后,制作tikzpicture不占用空间的更合适的方法是添加overlay

\documentclass[11pt,a5paper,twocolumn,twoside]{book}

\usepackage{geometry}
    \geometry{
        paper = a5paper,
        layout = a5paper,
        layoutsize = {148 mm, 210 mm},
        includehead = true,
        includefoot = true,
        inner = 1.5 cm,
        outer = 1 cm,
        top = 1.5 cm,
        bottom = 1.5 cm,
        columnsep = .8cm,
    }


\usepackage{tikz}

\newif\ifchapterpage

\usepackage{etoolbox}
    \makeatletter
        %
        \patchcmd\@outputdblcol
        {\normalcolor\vrule\@width\columnseprule}
        {\raisebox{.5\textheight}{%
            \begin{tikzpicture}[overlay]
                %\useasboundingbox;
                \ifchapterpage
                  %\message{page \thepage\space is a chapter page}
                  \fill[blue] (0,0) circle (.1cm);
                  \draw[blue] ++(90:.75) to ++(90:2);
                  \draw[blue] ++(-90:.75) to ++(-90:6);
                  \global\chapterpagefalse
                \else
                  %\message{page \thepage\space is not a chapter page}
                  \fill[blue] (0,0) circle (.1cm);
                  \draw[blue] ++(90:.75) to ++(90:6);
                  \draw[blue] ++(-90:.75) to ++(-90:6);             
                  \fi
            \end{tikzpicture}}}%\mydrawcolumnseprule}
        {}{}
    \makeatother

\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyhead[L]{\rightmark}
    \fancyhead[C]{\thepage}
    \fancyhead[R]{\chaptername}
    \fancyfoot{}

\usepackage{titlesec}
    \titleformat{\chapter}% command
        [block]% shape
        {\centering\itshape\huge}% format
        {}% label
        {0cm}% sep
        {{\normalsize The tale of\\}}% before-code
        [\global\chapterpagetrue\vspace{1cm}]% after-code
    \titlespacing{\chapter}% command
        {0pt}% left margin
        {0pt}% Vertical space before title
        {1cm}% Vertical space between title and text

\usepackage{lipsum}
\chapterpagetrue

\begin{document}

    \chapter*{Rhotingger}

    \lipsum[1-10]

    \chapter*{Blauinger}

    \lipsum[11-20]

\end{document}

在此处输入图片描述

答案2

这是使用 tikzpagenodes 和 everypage 的版本。请注意,\@outputdblcolparacol 或 multicol 不使用。我创建\mycolumnsep它是为了在将其添加到每个页面之前对其进行测试。

不要忘记运行两次,因为[remember picture]

顺便说一句,您也可以使用此方法来替换 fancyhdr。

\documentclass[11pt,a5paper,twocolumn,twoside]{book}

\usepackage{geometry}
    \geometry{
        paper = a5paper,
        layout = a5paper,
        layoutsize = {148 mm, 210 mm},
        includehead = true,
        includefoot = true,
        inner = 1.5 cm,
        outer = 1 cm,
        top = 1.5 cm,
        bottom = 1.5 cm,
        columnsep = .8cm,
    }


\usepackage{tikzpagenodes}
\usepackage{everypage}

\newif\ifchapterpage

\newcommand{\mycolumnsep}{\begin{tikzpicture}[overlay, remember picture]
                %\useasboundingbox;
                \ifchapterpage
                  %\message{page \thepage\space is a chapter page}
                  \fill[blue] (current page text area.center) circle (.1cm);
                  \draw[blue] (current page text area.center) ++(90:.75) to ++(90:2);
                  \draw[blue] (current page text area.center) ++(-90:.75) to ++(-90:6);
                  \global\chapterpagefalse
                \else
                  %\message{page \thepage\space is not a chapter page}
                  \fill[blue] (current page text area.center) circle (.1cm);
                  \draw[blue] (current page text area.center) ++(90:.75) to ++(90:6);
                  \draw[blue] (current page text area.center) ++(-90:.75) to ++(-90:6);             
                  \fi
\end{tikzpicture}}%\mydrawcolumnseprule}
\AddEverypageHook{\mycolumnsep}

\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyhead[L]{\rightmark}
    \fancyhead[C]{\thepage}
    \fancyhead[R]{\chaptername}
    \fancyfoot{}

\usepackage{titlesec}
    \titleformat{\chapter}% command
        [block]% shape
        {\centering\itshape\huge}% format
        {}% label
        {0cm}% sep
        {{\normalsize The tale of\\}}% before-code
        [\global\chapterpagetrue\vspace{1cm}]% after-code
    \titlespacing{\chapter}% command
        {0pt}% left margin
        {0pt}% Vertical space before title
        {1cm}% Vertical space between title and text

\usepackage{lipsum}
\chapterpagetrue

\begin{document}

    \chapter*{Rhotingger}

    \lipsum[1-10]

    \chapter*{Blauinger}

    \lipsum[11-20]

\end{document}

相关内容