Page LayoutAdd A Striped Border On All Four Page Edges Of One Chapter, Only

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
kurttodoroff
Posts: 24
Joined: Thu Feb 07, 2019 4:25 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by kurttodoroff »

I want to add a striped border to all four page edges, as depicted in the attachment.

I want this striped border to appear on the pages in chapter 2, only. (The document format requires that I use SECTION titles at the beginning of each chapter.)

Thank you for any and all assistance.

Kurt



An example of my code, follows:

\lof

\lot

\toc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% CHAPTER --> CHAPTER 1 INFORMATION %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cfoot{\textsc{\thepage~of~\protect\pageref{pagenumber-endofsection1}}}
\setcounter{page}{1}
\renewcommand{\thepage}{1-\arabic{page}}
\chapter{SECTION 1 TITLE}\label{SECTION1-TITLE} % SECTION 1 TITLE


\begin{multicols}{2}\index{ZZZZZ}\index[two]{ZZZZZ}

\section*{TABLE OF CONTENTS}

\minitoc

\phantomsection
\addcontentsline{toc}{section}{GENERAL}

\vspace{.25in}
\section*{INTRODUCTION}\label{section1-introduction}
\phantomsection
\addcontentsline{toc}{section}{\hspace{.1in}Introduction}
This section contains the introduction.

\section*{NEXT SECTION}
Lorem ipsum.

\section*{NEXT SECTION}
Lorem ipsum.

\section*{NEXT SECTION}
Lorem ipsum.

\end{multicols}

\label{pagenumber-endofsection1}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% CHAPTER --> CHAPTER 2 INFORMATION %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cfoot{\textsc{\thepage~of~\protect\pageref{pagenumber-endofsection2}}}
\setcounter{page}{1}
\renewcommand{\thepage}{2-\arabic{page}}
\chapter{SECTION 2 TITLE}\label{SECTION2-TITLE} % SECTION 2 TITLE


\begin{multicols}{2}\index{ZZZZZ}\index[two]{ZZZZZ}

\section*{TABLE OF CONTENTS}

\minitoc

\phantomsection
\addcontentsline{toc}{section}{GENERAL}

\vspace{.25in}
\section*{INTRODUCTION}\label{section2-introduction}
\phantomsection
\addcontentsline{toc}{section}{\hspace{.1in}Introduction}
This section contains the introduction.

\section*{NEXT SECTION}
Lorem ipsum.

\section*{NEXT SECTION}
Lorem ipsum.

\section*{NEXT SECTION}
Lorem ipsum.

\end{multicols}

\label{pagenumber-endofsection2}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% CHAPTER --> CHAPTER 3 INFORMATION %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\cfoot{\textsc{\thepage~of~\protect\pageref{pagenumber-endofsection3}}}
\setcounter{page}{1}
\renewcommand{\thepage}{3-\arabic{page}}
\chapter{SECTION 3 TITLE}\label{SECTION3-TITLE} % SECTION 3 TITLE


\begin{multicols}{2}\index{ZZZZZ}\index[two]{ZZZZZ}

\section*{TABLE OF CONTENTS}

\minitoc

\phantomsection
\addcontentsline{toc}{section}{GENERAL}

\vspace{.25in}
\section*{INTRODUCTION}\label{section3-introduction}
\phantomsection
\addcontentsline{toc}{section}{\hspace{.1in}Introduction}
This section contains the introduction.

\section*{NEXT SECTION}
Lorem ipsum.

\section*{NEXT SECTION}
Lorem ipsum.

\section*{NEXT SECTION}
Lorem ipsum.

\end{multicols}

\label{pagenumber-endofsection3}

\printindex

\printindex[two]

\end{document}
Attachments
Black Yellow Striped Border.png
Black Yellow Striped Border.png (7.19 KiB) Viewed 3428 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Bartman
Posts: 366
Joined: Fri Jan 03, 2020 2:39 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by Bartman »

Please try to provide a complete Infominimal working example and mark its code.

My example demonstrates how a solution could be implemented.

Code: Select all

\documentclass{report}
\usepackage{tikz}
\usepackage{eso-pic}
\usepackage{blindtext}

\usetikzlibrary{patterns.meta}

\tikzset{
  reverseclip/.style={
    insert path={
      [rounded corners=10pt]
      ([shift={(#1,-#1)}]current page.north west) 
      rectangle 
      ([shift={(-#1,#1)}]current page.south east)
    }
  },
  reverseclip/.default=1
}

\AddToShipoutPictureBG{%
  \ifnum\value{chapter}=2
    \begin{tikzpicture}[
      remember picture, 
      overlay
    ]
    \draw [
      preaction={fill=yellow},
      pattern={
        Lines[
          angle=45, 
          line width=5mm, 
          distance=2*\pgfkeysvalueof{/pgf/pattern keys/line width}
        ]
      }
    ] 
      (current page.north west) -- 
      (current page.north east) --
      (current page.south east) --
      (current page.south west) -- cycle [reverseclip]
    ;
    \end{tikzpicture}
  \fi
}

\begin{document}
\blinddocument
\blinddocument
\blinddocument
\end{document}
User avatar
MjK
Posts: 89
Joined: Fri Jan 28, 2022 6:09 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by MjK »

Bartman wrote:

Code: Select all

  \ifnum\value{chapter}=2
Be careful, this is also true, e.g., in Appendix B. So @kurttodoroff, please also have a look into the eso-pic manual to see, how you can remove all background pictures. Alternatively see lthooks-doc and ltshipout-doc for information about adding and removing labeled hook code to the shipout/background.
My main topics are KOMA-Script and other questions related to my packages. If I reply to any other topic or if you've not yet added a minimal working example, please do not expect any further response. And please don't forget to tag examples as code.
kurttodoroff
Posts: 24
Joined: Thu Feb 07, 2019 4:25 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by kurttodoroff »

Bartman,

Thank you for your prompt response.

I added your preamble code to my document preamble. I did not use the \blinddocument commands in the body. I will address this, shortly. I changed "\ifnum\value{chapter}=2" to "\ifnum\value{chapter}=3", seeing how I erred in my original posting.

I compiled the document. I am pleased with the result.

I visited the websites that MjK suggested. I also visited https://ctan.mirrors.hoobly.com/macros/ ... ndtext.pdf. I reviewed the document, yet, I am uncertain of the purpose of the \blindtext, \Blindtext, \blinddocument, \Blinddocument commands. Nevertheless, the chapter three appearance is spot on. I have not found any problems or anomalies with the other six chapters, nor, with the table of contents and indexes. Your code did not reformat chapter three, which is perfect.

I use the \chapter command in the appendix. The third appendix chapter displays the striped border. How can I exclude this chapter from this formatting?

My gratitude.

Regards,

Kurt
kurttodoroff
Posts: 24
Joined: Thu Feb 07, 2019 4:25 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by kurttodoroff »

MjK,

Thank you for your response.

I didn't understand it, until after I discovered that Appendix C in my document displayed the striped edges. This is likely due to my error, which I mentioned in my subsequent posting.

I reviewed the the three websites, which you recommended. I didn't find the solution to excluding Appendix C from displaying the striped edges. Do you have any suggestions?

Regards,

Kurt
Bartman
Posts: 366
Joined: Fri Jan 03, 2020 2:39 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by Bartman »

My modified suggestion takes MjK's alternative and uses the \newif command to check if the selected chapter is in the appendix.

Code: Select all

\documentclass{report}
\usepackage{tikz}
\usepackage{blindtext}

\usetikzlibrary{patterns.meta}

\tikzset{
  reverseclip/.style={
    insert path={
      [rounded corners=10pt]
      ([shift={(#1,-#1)}]current page.north west) 
      rectangle 
      ([shift={(-#1,#1)}]current page.south east)
    }
  },
  reverseclip/.default=1
}

\newif\ifappendix

\AddToHook{cmd/appendix/before}{\appendixtrue}

\AddToHook{shipout/background}{
  \unless\ifappendix
    \ifnum\value{chapter}=3
      \begin{tikzpicture}[
        remember picture, 
        overlay
      ]
      \draw [
        preaction={fill=yellow},
        pattern={
          Lines[
            angle=45, 
            line width=5mm, 
            distance=2*\pgfkeysvalueof{/pgf/pattern keys/line width}
          ]
        }
      ] 
        (current page.north west) -- 
        (current page.north east) --
        (current page.south east) --
        (current page.south west) -- cycle [reverseclip]
      ;
      \end{tikzpicture}
    \fi
  \fi
}

\begin{document}
\blinddocument
\blinddocument
\blinddocument
% This command or a similar one is needed to add the border 
% on the last page of the last chapter before the appendix.
\cleardoublepage
\appendix
\blinddocument
\blinddocument
\blinddocument
\end{document}
kurttodoroff
Posts: 24
Joined: Thu Feb 07, 2019 4:25 pm

Add A Striped Border On All Four Page Edges Of One Chapter, Only

Post by kurttodoroff »

Bartman and MjK,

I replaced your original code with your modified code. It is producing unexpected results.

I will share a preface to my observations.

My document contains seven chapters and an appendix which contains eight chapters. I used your original code, and, I compiled my document seven times, incrementing the chapter numeric values one through seven. Each of the corresponding seven chapters displayed the black and yellow edge stripes, properly. So did each of the corresponding seven appendix chapters.

I replaced your original code with your modified code. I compiled my document. The first two pages of chapter three did not display the black and yellow edge stripes. Several subsequent pages displayed them, properly. Then, the remainder of the pages did not. Appendix C did not display the edge stripes.

I compiled my document six more times, incrementing the chapter numeric values 1, 2, 4, 5, 6, 7. One of the chapters displayed the edge stripes on all pages, while all of the other chapters displayed the edge stripes on some pages, but, not others. I have been unable to identify a pattern in the pages (and, their corresponding source code) that are absent of edge stripes. None of the corresponding appendix chapters displayed the edge stripes.

I compiled the document three times, during each exercise.

Regards,

Kurt
Post Reply