0

I added a new environment to my Cornell-styled notes: titlednote

It allows adding a title to a note which should also generate a bookmark below its term. But since terms are implemented with a tcolorbox overlay the bookmark of a titlednote that defines a term is not below the overlay.

Here is an example where the Date bookmark should be below Meeting Context exampe

The cornell.cls for this example is as follows:

\ProvidesClass{cornell}
\LoadClass[a4paper]{article}
\usepackage{tcolorbox}
\tcbuselibrary
{
    breakable,% Allows tcolorboxes to break across pages
    hooks,% Allows usage of hooks, like having an overlay only for the first part of a broken box
    skins,% Used to style the boxes with tikz
    xparse% Used to define document environments and commands
}

\usepackage[margin=2cm]{geometry} % Change geometry of pages
\usepackage[parfill]{parskip} % Modify parindent and parskip
\usepackage{enumitem} % Modify itemize spacing
\setitemize
{
    itemsep=0pt,
    parsep=2pt,
}

\usepackage{bookmark} % Add bookmarks to the resulting PDF
\usepackage{hyperref}
\hypersetup
{
    colorlinks   = true, % Colour links instead of ugly boxes
    urlcolor     = blue, % Colour for external hyperlinks
    linkcolor    = blue, % Colour of internal links
    citecolor    = red   % Colour of citations
}

\date{}

\tcbset
{
    colframe=black,
    colupper=black,
    opacitybacktitle=1,
    opacitytext=1,
    fonttitle=\large\bfseries\sffamily,
}

\NewTColorBox[]{titlebox}{ o }
{
    width=\textwidth,
    lowerbox=invisible,
    bookmark*={level=0}{\@title}
}

\renewcommand{\maketitle}
{
    \vspace{-3em}
    \begin{titlebox}
        \Huge{\sffamily{\@title}}
    \end{titlebox}
}

\NewTColorBox[]{extra}{ m }
{
    width=\textwidth,
    title=#1,
    bookmark*={level=1}{#1},
}

\NewTColorBox[]{term}{ m }
{
    width=.325\textwidth,
    bookmark*={level=1}{#1},
}

\NewTColorBox[]{note}{ o }
{
    enhanced,
    breakable,
    enlarge left by=.34\textwidth,
    width=.66\textwidth,
    parbox=false,% restore main text formatting behavior
    overlay unbroken={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    },
    overlay first app={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    }
}

\NewTColorBox[]{titlednote}{ om }
{
    enhanced,
    breakable,
    title=#2,
    bookmark*={level=2}{#2},
    enlarge left by=.34\textwidth,
    width=.66\textwidth,
    parbox=false,% restore main text formatting behavior
    overlay unbroken={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    },
    overlay first app={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    }
}

And the sample that produces the screenshot is as follows:

\documentclass{cornell}

\title{Some meeting notes}

\begin{document}
\maketitle

\begin{titlednote}[Meeting Context]{Date}
    Wednesday
\end{titlednote}
\begin{titlednote}{Moderator}
    Max Mustermann
\end{titlednote}
\begin{titlednote}{Participants}
    \begin{itemize}
        \item A
        \item B
        \item C
        \item D
    \end{itemize}
\end{titlednote}

\end{document}

I tried to modify the titlednode environment by changing the term from an overlay to a separate tcolorbox. That fixes the issue with the bookmark, but it introduces a layouting issue:

\NewDocumentEnvironment{titlednote}{ om }
{
    \IfNoValueF{#1}{
        \begin{term}{#1}
            #1
        \end{term}
    }
    \begin{tcolorbox}[
            enhanced,
            breakable,
            title=#2,
            bookmark*={level=2}{#2},
            enlarge left by=.34\textwidth,
            width=.66\textwidth,
            parbox=false,% restore main text formatting behavior
        ]
}
{
    \end{tcolorbox}
}

The result looks like this:

modified solution

I did not find a way to calculate the (dynamic) height of the term tcolorbox in order to use negative vspace. That would solve the issue but there must be a way to fix this issue.

3
  • 1
    How about removing bookmark* from term and put IfValueT={#1}{bookmark*={level=1}{#1}}, bookmark*={level=2}{#2}, into titlednote? That should give the desired sequence (for your first code). Feb 3 at 16:39
  • @ThomasF.Sturm that solved the issue. Thank you very much! I did not know it is possible to use functions like IfValueT in the options of a tcolorbox. Is this specific to your package or is that something that xparse allows?
    – L. Resch
    Feb 3 at 17:09
  • 1
    IFValueT is from the xparse library of tcolorbox; of course, based on xparse. Feb 4 at 16:03
1

A solution to the issue was provided by @ThomasF.Sturm as a comment. For sake of completeness here is it applied to my question.

Instead of defining the bookmark in the overlay, define the bookmark in the parent tcolorbox. In order to do so one can check if the optional parameter for a term was provided or not.

\NewTColorBox[]{term}{ m }
{
    width=.325\textwidth,
%    bookmark*={level=1}{#1}, %<< Redundant, now set by titlednote environment
}

\NewTColorBox[]{titlednote}{ om }
{
    enhanced,
    breakable,
    title=#2,
    IfValueT={#1}{bookmark*={level=1}{#1}}, %<< Set term bookmark only if it was provided
    bookmark*={level=2}{#2},
    enlarge left by=.34\textwidth,
    width=.66\textwidth,
    parbox=false,
    overlay unbroken={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    },
    overlay first app={
        \IfNoValueF{#1} {%
            \node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34\textwidth]frame.north west) {
                \begin{term}{#1}
                    #1
                \end{term}
            };
        }{}
    }
}

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.