TeX - LaTeX Asked by L. Resch on July 9, 2021
I tried to extend this class with breakable tcolorboxes.
For some reason this does not work at all.
Here is my .cls file where I marked my change:
ProvidesClass{cornell}
LoadClass[a4paper]{article}
usepackage{tcolorbox}
tcbuselibrary{breakable,skins,xparse}
usepackage{parcolumns} % Used to create two columns
usepackage{bookmark} % Add bookmarks to the resulting PDF
usepackage[margin=2cm]{geometry} % Change geometry of pages
usepackage{hyperref} % Default hyperref setup
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{}
renewcommand{maketitle}{%
vspace{-3em}
pdfbookmark[0]{@title}{title}
begin{tcolorbox}[width=textwidth,lowerbox=invisible]
Hugesffamily @title
end{tcolorbox}
vspace{2em}
}
DeclareDocumentCommandpreread{ m m }
{
pdfbookmark[1]{Introduction}{intro}
begin{tcolorbox}[width=textwidth]
#1
tcblower
#2
end{tcolorbox}
}
DeclareDocumentCommandnote{ o m }
{
IfNoValueT{#1} {
vspace{-1.5em}
}{}
begin{parcolumns}[colwidths={1=.33textwidth},nofirstindent]{2}
colchunk{
IfNoValueF{#1} {
pdfbookmark[1]{#1}{note}
begin{tcolorbox}[lowerbox=invisible,box align=top]
#1
end{tcolorbox}
}{}
}
colchunk{
begin{tcolorbox}[enhanced,lowerbox=invisible,box align=top,breakable] % <<< HERE I ADDED BREAKABLE
#2
end{tcolorbox}
}
end{parcolumns}
}
DeclareDocumentCommandsummary{ m }
{
vfill
pdfbookmark[1]{Summary}{summary}
begin{tcolorbox}[
enhanced,
floatplacement=!b,
float,
colframe=black,
colupper=black,
opacitybacktitle=1,
opacitytext=1,
segmentation style={black!55,solid,opacity=0,line width=3pt},
title=Summary,
fonttitle=largebfseriessffamily]
#1
end{tcolorbox}
}
And here is a sample file:
documentclass{cornell}
usepackage{lipsum}
title{A topic we're taking notes on}
begin{document}
maketitle
preread
{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]}
note{lipsum[6-7]}
summary{A fabulous summary.}
note{lipsum[6]}
note{lipsum[9-12]}
note{lipsum[10-20]}
end{document}
When compiling this the results are really awkward.
Here should be a break across the two pages:
Here are actually breaks within a single page:
Does anyone know how to solve this issue?
I suggest to replace parcolumns
package by paracol
into cornell.cls
.
May be you need some more adjustments, but following code worked for me:
ProvidesClass{cornell}
LoadClass[a4paper]{article}
usepackage{tcolorbox}
tcbuselibrary{breakable,skins,xparse}
usepackage{paracol} % Used to create two columns
usepackage{bookmark} % Add bookmarks to the resulting PDF
usepackage[margin=2cm]{geometry} % Change geometry of pages
usepackage{hyperref} % Default hyperref setup
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{}
renewcommand{maketitle}{%
vspace{-3em}
pdfbookmark[0]{@title}{title}
begin{tcolorbox}[width=textwidth,lowerbox=invisible]
Hugesffamily @title
end{tcolorbox}
vspace{2em}
}
DeclareDocumentCommandpreread{ m m }
{
pdfbookmark[1]{Introduction}{intro}
begin{tcolorbox}[width=textwidth]
#1
tcblower
#2
end{tcolorbox}
}
DeclareDocumentCommandnote{ o m }
{
% The original `cornell.cls` has these lines uncommented. They cut the
% space between fragments (`notes`).
% IfNoValueT{#1} {
% vspace{-1.5em}
% }{}
columnratio{.33}
begin{paracol}{2}
begin{leftcolumn}
IfNoValueF{#1} {
pdfbookmark[1]{#1}{note}
begin{tcolorbox}[lowerbox=invisible,box align=top]
#1
end{tcolorbox}
}{}
end{leftcolumn}
begin{rightcolumn}
begin{tcolorbox}[enhanced,lowerbox=invisible,box align=top,breakable] % <<< HERE I ADDED BREAKABLE
#2
end{tcolorbox}
end{rightcolumn}
end{paracol}
}
DeclareDocumentCommandsummary{ m }
{
vfill
pdfbookmark[1]{Summary}{summary}
begin{tcolorbox}[
enhanced,
floatplacement=!b,
float,
colframe=black,
colupper=black,
opacitybacktitle=1,
opacitytext=1,
segmentation style={black!55,solid,opacity=0,line width=3pt},
title=Summary,
fonttitle=largebfseriessffamily]
#1
end{tcolorbox}
}
With previous class, the result looks like:
Second solution
In case that all left column boxes are like labels ore just a few words, it's also possible to forget the paracol
package and use only a breakable and narrow tcolorbox
with another box attached to the left.
The note
command could be:
DeclareDocumentCommandnote{ o m }
{
% IfNoValueT{#1} {
% vspace{-1.5em}
% }{}
begin{tcolorbox}[enhanced, breakable,
enlarge left by=.34textwidth, width=.66textwidth,
overlay={
IfNoValueF{#1} {
pdfbookmark[1]{#1}{note}
node[anchor=north west, outer sep=0pt, inner sep=0pt] at ([xshift=-.34textwidth]frame.north west) {begin{tcolorbox}[width=.325textwidth]#1end{tcolorbox}};
}{}
}
]
#2
end{tcolorbox}
}
Some adjustments have to be done to box sizes and interbox space but the result is quite similar:
Correct answer by Ignasi on July 9, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP