1

I am preparing a comprehensive lecture note that will cover the interconnected topics of three courses. The courses are:

  • Course 1: Fundamental of Topic (including some A and some B)
  • Course 2: Details of A
  • Course 3: Details of B

Now, I am looking for a possibility to mark content that is exclusively in Course 2 or 3. What possibilities do you see, to illustrate such a categorization of content? And what LaTeX packages are available for that?

I was thinking of colored stripes along the margin, colored symbols before the headings, etc. In general, I like The Legrand Orange Book or elegantbook, but I haven't seen that they provide such a marking/category.

In a general way, I would need a table of contents that has an extra category besides numbering, title and page.

Looking forward to read your thoughts and ideas! Maybe someone can provide examples of similar thinks already done. Thank you!

1 Answer 1

1

CODE HAS BEEN UPDATED, I THINK MY NEW ANSWER IS BETTER; Old with bophook (outdated package) is at the bottom!

New Code

\documentclass{article} %% Book works aswell, I just don't like
\usepackage{blindtext} %% Just for testing

\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{etoolbox} % provides if-else-conditionals
\usepackage{eso-pic} % provides the \AddToShipoutPictureBG command 

%% TOPIC A
\def \currentTopicColor{white!100}

\newcommand{\Topic}[0]{
    \begin{tikzpicture}[remember picture,overlay]
        \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
        \fill [\currentTopicColor,line width=10pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
    \end{tikzpicture}
    }

\newcounter{brain}
\setcounter{brain}{0}
\newcounter{didWeJustChangePage}
\setcounter{didWeJustChangePage}{0} %Sæt 0 ved hver topic
\AddToHook {shipout/background}{
    \ifodd\thebrain
        {
            \setcounter{didWeJustChangePage}{1}
            \begin{tikzpicture}[remember picture,overlay]
            \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
            \fill [\currentTopicColor,line width=0pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
            \end{tikzpicture}
        }
    \else{
        \setcounter{didWeJustChangePage}{1}
        \setcounter{brain}{1}
    }\fi
}

\newcommand{\previoustopicdrawing}{
    \begin{tikzpicture}[remember picture,overlay]
            \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
            \fill [yellow,line width=0pt] ($ (A) + (1cm,7cm) $) rectangle ($ (A) + (2cm,-0.4cm) $);
            \end{tikzpicture}
}

\newcommand{\topicdrawing}[1]{
    \ifodd\thedidWeJustChangePage
    {
    \begin{tikzpicture}[remember picture,overlay]
            \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
            \fill [\currentTopicColor,line width=10pt] ($ (A) + (1cm,40cm) $) rectangle ($ (A) + (2cm,-0.4cm) $);
            \fill [#1,line width=10pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
        \end{tikzpicture}
    }
    \else{
        \begin{tikzpicture}[remember picture,overlay]
            \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};  
            \fill [#1,line width=10pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
        \end{tikzpicture}
    }\fi
}

\def \TopicAColor{orange!20}
\def \TopicBColor{green!20}
\def \TopicCColor{red!20}
\def \TopicDColor{blue!20}
\def \TopicFColor{yellow!20}

\newcommand{\TopicA}{
    \topicdrawing{\TopicAColor}
    \def \currentTopicColor{\TopicAColor}
    \setcounter{brain}{0}
    \setcounter{didWeJustChangePage}{0}
    }
\newcommand{\TopicB}{
    \topicdrawing{\TopicBColor}
    \def \currentTopicColor{\TopicBColor}
    \setcounter{brain}{0}
    \setcounter{didWeJustChangePage}{0}
    }
\newcommand{\TopicC}{
    \topicdrawing{\TopicCColor}
    \def \currentTopicColor{\TopicCColor}
    \setcounter{brain}{0}
    \setcounter{didWeJustChangePage}{0}
    }
\newcommand{\TopicD}{
    \topicdrawing{\TopicDColor}
    \def \currentTopicColor{\TopicDColor}
    \setcounter{brain}{0}
    \setcounter{didWeJustChangePage}{0}
    }
\newcommand{\TopicF}{
    \topicdrawing{\TopicFColor}
    \def \currentTopicColor{\TopicFColor}
    \setcounter{brain}{0}
    \setcounter{didWeJustChangePage}{0}
    }
\newcommand{\TopicRemove}{
    \topicdrawing{white!100}
    \def \currentTopicColor{white!100}
    \setcounter{brain}{0}
    \setcounter{didWeJustChangePage}{0}
    }
    
\begin{document}
\tableofcontents
\section{Fundamental of Topic  (including some A and some B)}
\TopicF
\subsection{Here is some text about fundamental}
\noindent\blindtext[2]
\bigskip\par
\TopicA 
\subsection{Here is some text about topic A} 
\noindent \blindtext[2] \par
\TopicB
\subsection{Here is some text about topic B} 
\blindtext[2] \par 

\TopicRemove
\par
\subsection{Here is some text with no topic} 
\blindtext[3] \par

\TopicB
\subsection{Here is some more text about topic B} 
\blindtext[2] \par 
\end{document}

And the output of the MWE

enter image description here

Old code with outdated package I'm not quite sure what you want with the table of content, however you can make colored stripes along the margins with a bunch of different packages. Below is an example code, but first how the output of the code.

enter image description here

\documentclass{article} %% Book works aswell, I just don't like
\usepackage{blindtext} %% Just for testing

%% NOT IMPORTANT BUT I JUST NEED
\usepackage{fancyhdr}
\usepackage{lastpage}
\newcommand{\titlesetup}[4]{
        \title{#2 }
        \author{af #1}
        \date{#3}
        \pagestyle{fancy}
            \fancyhf{}
            \setlength\headheight{15pt}
            \fancyhead[L]{#4}
            \fancyhead[R]{#2}
            \fancyfoot[R]{\thepage}
         
    
          \fancypagestyle{plain}{ 
          \fancyhf{}
    \rfoot{\thepage}
    } }


\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{etoolbox} % provides if-else-conditionals
\usepackage{eso-pic} % provides the \AddToShipoutPictureBG command which adds content to background of every page
\usepackage{bophook} %% Lader os gøre det på hver side


\newtoggle{TopicA} % default: deactivated
    \AddToShipoutPictureBG{% this command adds content to background of every page
        \iftoggle{TopicA}{
        \AtBeginPage{\TopicA}
    }{%else, but we need no else ;)
    }}
\newtoggle{TopicE} % default: deactivated
    \AddToShipoutPictureBG{% this command adds content to background of every page
      \iftoggle{TopicE}{
      \AtBeginPage{\TopicE}
     }{%else, but we need no else ;)
    }}
\newtoggle{TopicD} % default: deactivated

\AddToShipoutPictureBG{% this command adds content to background of every page
    \iftoggle{TopicD}{
    \AtBeginPage{\TopicD}
     }{%else, but we need no else ;)
    }}
    
\newtoggle{NOTOPIC} % default: deactivated
    \AddToShipoutPictureBG{% this command adds content to background of every page
      \iftoggle{NOTOPIC}{
      \AtBeginPage{\TopicRemove}
     }{%else, but we need no else ;)
    }}
%% TOPIC D
\newcommand{\TopicD}[0]{
    \begin{tikzpicture}[remember picture,overlay]
        \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
        \fill [blue!20,line width=10pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
    \end{tikzpicture}
     \TR
    \toggletrue{TopicD} %% Toggle D on
    }


%% TOPIC A
\newcommand{\TopicA}[0]{
    \begin{tikzpicture}[remember picture,overlay]
        \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
        \fill [orange!20,line width=10pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
    \end{tikzpicture}
     \TR %% Toggles all other enviroments off
    \toggletrue{TopicA} %% Toggle A on
    }
    
%% TOPIC E
\newcommand{\TopicE}[0]{
    \begin{tikzpicture}[remember picture,overlay]
        \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
        \fill [green!20,line width=10pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
    \end{tikzpicture}
    \TR
    \togglefalse{NOTOPIC}
    }
\newcommand{\TR}[0]{
    \togglefalse{TopicA}
    \togglefalse{TopicD}
    \togglefalse{TopicE}
    \togglefalse{NOTOPIC}
}
\newcommand{\TopicRemove}[0]{
    \TR
    \toggletrue{NOTOPIC}
\begin{tikzpicture}[remember picture,overlay]
        \path[draw=black] let \p1 = ($ (current page.west)$) in node(A)  at (\x1,0) {};
        \fill [white!100,line width=0pt] ($ (A) + (1cm,0.4cm) $) rectangle ($ (A) + (2cm,-40cm) $);
\end{tikzpicture}
 
 

}
\begin{document}
\titlesetup{Test of Test}{Test}{Test}{Test}
\tableofcontents
\section{Fundamental of Topic  (including some A and some B)}
\TopicD 
\subsection{Here is some text about fundamental}
\noindent\blindtext[2]
\bigskip\par
\TopicA 
\subsection{Here is some text about topic A} 
\noindent \blindtext[2] \par
\TopicE
\subsection{Here is some text about topic B} 
\blindtext[2] \par 

\TopicRemove
\par
\subsection{Here is some text with no topic} 
\blindtext[3] \par

\TopicA
\subsection{Here is some more text about topic B} 
\blindtext[2] \par 
\end{document}

Found some "inspiration here", might help explain things a bit :):

Colored Margins How to set colored ruled margins for some pages?

Tikz one coordinate TikZ: Node at same x-coordinate as another node, but specified y-coordinate?

Do some on the start of page(make colored margins) Execute a command at the start of every page

E-tools package http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/etoolbox/etoolbox.pdf#page=3&zoom=100,0,0

4
  • 1
    Welcome to TeX.SE! Can you please add an screenshot of your result to your answer?
    – Mensch
    Commented Oct 2, 2021 at 23:27
  • The package bophook was not available in my environment. Then I learned from tex.stackexchange.com/questions/580395/atbeginpage-itemize that it should be replaced by atbegshi as the other package is 20 years old and usage is not advised. It now works with \AtBeginShipout{...} but the compilation time of the short document is very long. Too long to use it. Any ideas?
    – Philipp
    Commented Oct 10, 2021 at 22:34
  • 1
    @Philipp , if you are still in need of an answer , then take a look at my updated code
    – FireDuckz
    Commented Sep 30, 2022 at 16:45
  • Great, thank you! I will try this new code as I never got the old one running in a productive document due to the compilation time.
    – Philipp
    Commented Oct 2, 2022 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .