1

I am aggregating a document class for taking Cornell-styled notes. For this purpose, I am using the tcolorbox package and arrange them into two columns. terms on the left and notes related to these terms on the right. Here is an example:

sample of layout

Now I would like to add the possibility of highlighting certain parts of the notes with text in the "margin" introduced with the term column. Something like this:

sample of wanted behavior

Here is the full class as of right now:

\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*={rellevel=1}{#1},
}

\NewTColorBox[]{term}{ m }
{
    width=.325\textwidth,
}

% A note is a tcolorbox in the right column. It may be associated to a
% term which is provided as an optional argument. If a term is provided
% another left-aligned tcolorbox is created with a bookmark.
% It is also possible to give the note itself a title. In this case the
% note tcolorbox is given the provided title and a bookmark for this
% title is created.
\NewTColorBox[]{note}{ o d<> }
{
    enhanced,
    breakable,
    IfValueT={#1}{bookmark*={rellevel=1}{#1}},
    IfValueT={#2}{
        bookmark*={rellevel=2}{#2},
        title=#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}
            };
        }{}
    }
}

\NewDocumentEnvironment{summary}{}
{
    \vfill
    \begin{tcolorbox}[
        floatplacement=!b,
        float,
        title=Summary,
        bookmark*={level=1}{Summary},
        parbox=false,% restore main text formatting behavior
    ]
}
{
    \end{tcolorbox}
}

And here is the sample file:

\documentclass{cornell}

\usepackage{lipsum}

\title{A topic we're taking notes on}

\begin{document}
\maketitle

\begin{extra}{Introduction}
    This can be used to introduce what is about to come, like
    \begin{enumerate}
        \item{What's the first question this section will answer?}
        \item{What's the second question?}
    \end{enumerate}
\end{extra}

\begin{note}[Some key term]
    \begin{itemize}
        \item{A cool thing}
        \item{Another cool thing}
        \item{Not all things are cool}
    \end{itemize}

    That has another paragraph.
\end{note}

\begin{note}<This is a titled noted with a very long title that should wrap around>
    \lipsum[10]
\end{note}

\begin{summary}
    A fabulous summary.

    With multiple paragraphs.
\end{summary}

\end{document}
5
  • 1
    A simple overlayed and remembered node could be used to do that.
    – Ignasi
    Feb 4 at 17:07
  • @Ignasi not really sure what you mean by that. Are these tikz terms?
    – L. Resch
    Feb 4 at 18:54
  • Paracol can handle uneven columns over multiple pages, although \switchcolumn* would not allow you to interrupt a tcolorbox in progress. You could just leave one column blank and overlay tikzpictures even with the current baseline. See tikzpagenodes and (current page text area.west). Feb 5 at 5:42
  • See tex.stackexchange.com/questions/163567/… for doing this with normal margins. IIRC, tcolorbox redefines tikzpicture to allow them inside a tcolorbox. Feb 5 at 5:49
  • 1
    I was thinking more along the lines of \marginpar or the \graffito command from the classicthesis package. See this image for an example.
    – L. Resch
    Feb 5 at 8:46
0

It is possible to move the margin into the text area thus creating the wished effect. The details can be seen here.

This is the important part:

\usepackage{geometry} % Change geometry of pages
\usepackage{marginnote} % Used to create notes in the margin
\renewcommand*{\raggedleftmarginnote}{} % Align notes to the left
\reversemarginpar
\geometry{
    margin=2cm,
    marginparsep=-.35\textwidth,
    marginparwidth=.325\textwidth,
}

The result looks like this: the result

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.