7

I wish I could set a different columsep on the page if it is the title page of the chapter. So far I've tried using a conditional ifchapterpage with the code within makeatother found in here (by @Skillmon) but it doesn't recognize the condition I put and nothing changes. How can I change the columnsep for just the pages with chapter titles? I'm compiling it with 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}
11

You tell TeX in the beginning that if this is not a chapter page, it should patch the command @outputdblcol in one way, and otherwise in another. However, in the preamble this is not a chapter page. You need to make TeX check for every single page. To this end I moved \ifchapterpage into the TikZ picture. Also you never set the conditional to false. I added this reset, too. Finally, the arguably more appropriate way to make a tikzpicture take no space is to add 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}

enter image description here

  • You are amazing!! Thank you very much. – Levy Jul 4 at 4:54
2

Here is a version which uses tikzpagenodes and everypage. Note that \@outputdblcol is not used by paracol or multicol. I created \mycolumnsep in order to test it before adding it to every page.

Don't forget to run it twice, due to [remember picture].

BTW, you can also use this approach to replace 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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.