# How to match width of tcolorbox box in this Cornell notes template?

Working from this answer, I'd like to create a template that includes a box below the title, of the same width as the title box. This would serve as a place for things like a summary of what's to come, or a series of questions to be answered in the rest of the document.

I've started to separate the code in the answer above into a .cls file, and I've managed to make a new command for the summary box. I can't determine how to set the width of this box so that it matches the right and left edges of the title box and the paired boxes below.

How can one align these edges?

My cornell.cls file:

\ProvidesClass{cornell}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\date{}
\usepackage{background}

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{red}
\SetBgContents{\rule[0em]{0pt}{\textheight}}
\SetBgHshift{-2.3cm}
\SetBgVshift{0cm}

\usepackage{lipsum}% just to generate filler text for the example
\usepackage[margin=2cm]{geometry}

\usepackage{tikz}
\usepackage{tikzpagenodes}

\parindent=0pt

\usepackage{xparse}
{
\begin{tcolorbox}[colback=white, width=\textwidth]
#1
\tcblower
#2
\end{tcolorbox}
}
\DeclareDocumentCommand\topic{ m m g g g g g}
{
\begin{tcolorbox}[sidebyside,sidebyside align=top,opacityframe=0,opacityback=0,opacitybacktitle=0, opacitytext=1,lefthand width=.3\textwidth]
\begin{tcolorbox}[colback=red!05,colframe=red!25,sidebyside align=top,width=\textwidth,before skip=0pt]
#1.\end{tcolorbox}%
\tcblower
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth,before skip=0pt]
#2
\end{tcolorbox}
\IfNoValueF {#3}{
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth]
#3
\end{tcolorbox}
}
\IfNoValueF {#4}{
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth]
#4
\end{tcolorbox}
}
\IfNoValueF {#5}{
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth]
#5
\end{tcolorbox}
}
\IfNoValueF {#6}{
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth]
#6
\end{tcolorbox}
}
\IfNoValueF {#7}{
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth]
#7
\end{tcolorbox}
}
\end{tcolorbox}
}

\def\summary#1{
\begin{tikzpicture}[overlay,remember picture,inner sep=0pt, outer sep=0pt]
\node[anchor=south,yshift=-1ex] at (current page text area.south) {%
\begin{minipage}{\textwidth}%%%%
\begin{tcolorbox}[colframe=white,opacityback=0]
\begin{tcolorbox}[enhanced,colframe=black,fonttitle=\large\bfseries\sffamily,sidebyside=true, nobeforeafter,before=\vfil,after=\vfil,colupper=black,sidebyside align=top, lefthand width=.95\textwidth,opacitybacktitle=1, opacitytext=1,
%segmentation style={black!55,solid,opacity=0,line width=3pt},
title=Summary
]
#1
\end{tcolorbox}
\end{tcolorbox}
\end{minipage}
};
\end{tikzpicture}
}


My examplenotes.tex file:

\documentclass{cornell}
\begin{document}

\title{
\vspace{-3em}
\begin{tcolorbox}[colframe=white,opacityback=0]
\begin{tcolorbox}
\Huge\sffamily Cornell Notes on Something
\end{tcolorbox}
\end{tcolorbox}
\vspace{-3em}
}
\maketitle

\topic{Key term}%
{Definition}%
{Some other stuff about the term/concept.}%

\topic{Here's another question.}{\lipsum[1]}%
{\lipsum[2]}%

\summary{Summary for the page.}

\topic{Here's another question to begin the new page.}{\lipsum[3]}%
{\lipsum[4]}%
{\lipsum[5]}%

\summary{And another summary that will float to the bottom of the next page.}

\end{document}

• With other words: The preread box should have the same width like the topic box (the one with Cornell notes on something)? – user31729 Nov 3 '15 at 18:13
• Yes @Christian that's precisely right. I've tried fiddling with width, but that didn't solve the left alignment. I gather there's something else I'm missing. – Sean Easter Nov 3 '15 at 18:17

This is not an answer but an example which shows the problem. I don't know why, but all your tcolorboxes are declared inside other tcolorboxes. This encapsulation introduces changes in \textwidth which is different for preread (fixed by geometry) and for topic pair of boxes.

As you can see if preread is introduced into a tcolorbox all margins are equal. Now you must decide if all these external boxes are necessary or not.

\documentclass{cornell}
\usepackage{lipsum}
\begin{document}

\title{
\vspace{-3em}
\begin{tcolorbox}[colframe=white,opacityback=0]
\begin{tcolorbox}
\Huge\sffamily Cornell Notes on Something
\end{tcolorbox}
\end{tcolorbox}
\vspace{-3em}
}
\maketitle

\lipsum[1]

\begin{tcolorbox}
\end{tcolorbox}

\topic{Key term}%
{Definition}%
{Some other stuff about the term/concept.}%

\topic{Here's another question.}{\lipsum[1]}%
{\lipsum[2]}%

\summary{Summary for the page.}

\topic{Here's another question to begin the new page.}{\lipsum[3]}%
{\lipsum[4]}%
{\lipsum[5]}%

\summary{And another summary that will float to the bottom of the next page.}

\end{document}


• (+1) You find the nested boxes as weird as I do ;-) – user31729 Nov 3 '15 at 18:33
• Thanks! I confess I took the nesting from the linked question without much scrutiny. It struck me as a little peculiar, but I'm too new to have known whether this is the TeX equivalent of a code smell. – Sean Easter Nov 3 '15 at 19:09

As referenced in another answer, this is due to the choice to nest tcolorbox boxes inside each other. The approach below avoids this using parcolumns.

The .cls file:

\ProvidesClass{cornell}
\usepackage{tcolorbox}
\usepackage{parcolumns}
\usepackage{xparse}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\tcbuselibrary{skins}

\date{}
\usepackage[margin=2cm]{geometry}
\DeclareDocumentCommand\cornelltitle{ m }
{
\vspace{-3em}
\begin{tcolorbox}[width=\textwidth,lowerbox=invisible]
\Huge\sffamily #1
\end{tcolorbox}
\vspace{-3em}
}

{
\begin{tcolorbox}[width=\textwidth]
#1
\tcblower
#2
\end{tcolorbox}
}

\DeclareDocumentCommand\note{ o m }
{
\begin{parcolumns}[colwidths={1=.3\textwidth},nofirstindent]{2}
\colchunk{
\IfNoValueF{#1} {
\begin{tcolorbox}[lowerbox=invisible, box align=top]
#1
\end{tcolorbox}
}{}
}
\colchunk{
\begin{tcolorbox}[lowerbox=invisible, box align=top]
#2
\end{tcolorbox}
}
\end{parcolumns}
}
\DeclareDocumentCommand\summary{ m }
{
\begin{tcolorbox}[floatplacement=b,float]
Summary
\tcblower
#1
\end{tcolorbox}
}


Sample .tex file:

\documentclass{cornell}
\begin{document}
\title{
\cornelltitle{A topic we're taking notes on}
}
\maketitle
{Questions}
{
\begin{enumerate}
\item{What's the first question this section will answer?}
\item{What's the second question?}
\end{enumerate}
}
\note[Some key term]
{
\begin{itemize}
\item{A cool thing}
\item{Another cool thing}
\item{Not all things are cool}
\end{itemize}
}
\note[Another term]
{
\lipsum[4]
}
\note{\lipsum[5]}

\summary{A fabulous summary}
\note[]{\lipsum[6]}
\end{document}