In Cornell Notes - A lyx or latex solution needed, I like Fran's Cornell note-taking template. Does anyone know how to allow indexing in the red and blue text boxes? I want to use the \index{} command to make an index for my notes but when I use \index{} in one of Fran's text boxes, the text box is empty.
Asked
Active
Viewed 1,405 times
3
1 Answers
3
I took the code from the linked question and added \index{some text} inside the \cornell box command. Using \index{} alone of course will lead to empty index entries, showing nothing!
In my opinion it's not go idea to index the whole box text, but only some key words, so I refrained from providing a wrapper command like \textforbox{foo} where foo appears both as the text inside the box and as index entry. (This would require more setup anyway, since \index might have an optional argument if imakeidx is used, and the subentry syntax makes it more difficult too)
\documentclass[a4paper]{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\title{
\vspace{-3em}
\begin{tcolorbox}
\Huge\sffamily Cornell Notes on Something
\end{tcolorbox}
\vspace{-3em}
}
\usepackage{imakeidx}
\date{}
\usepackage{background}
\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{red}
\SetBgContents{\rule[0em]{4pt}{\textheight}}
\SetBgHshift{-2.3cm}
\SetBgVshift{0cm}
\usepackage{lipsum}% just to generate filler text for the example
\usepackage[margin=2cm]{geometry}
\usepackage{lipsum}% just to generate dummy text for the example
%\url{http://tex.stackexchange.com/a/314/86}
\makeatletter
\def\cornell{\@ifnextchar[{\@with}{\@without}}
\def\@with[#1]#2#3{
\begin{tcolorbox}[enhanced,colback=gray,colframe=black,fonttitle=\large\bfseries\sffamily,sidebyside=true, nobeforeafter,before=\vfil,after=\vfil,colupper=blue,sidebyside align=top, lefthand width=.3\textwidth,
opacityframe=0,opacityback=.3,opacitybacktitle=1, opacitytext=1,
segmentation style={black!55,solid,opacity=0,line width=3pt},
title=#1
]
\begin{tcolorbox}[colback=red!05,colframe=red!25,sidebyside align=top,
width=\textwidth,nobeforeafter]#2\end{tcolorbox}%
\tcblower
\sffamily
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth,nobeforeafter]
#3
\end{tcolorbox}
\end{tcolorbox}
}
\def\@without#1#2{
\begin{tcolorbox}[enhanced,colback=white!15,colframe=white,fonttitle=\bfseries,sidebyside=true, nobeforeafter,before=\vfil,after=\vfil,colupper=blue,sidebyside align=top, lefthand width=.3\textwidth,
opacityframe=0,opacityback=0,opacitybacktitle=0, opacitytext=1,
segmentation style={black!55,solid,opacity=0,line width=3pt}
]
\begin{tcolorbox}[colback=red!05,colframe=red!25,sidebyside align=top,
width=\textwidth,nobeforeafter]#1\end{tcolorbox}%
\tcblower
\sffamily
\begin{tcolorbox}[colback=blue!05,colframe=blue!10,width=\textwidth,nobeforeafter]
#2
\end{tcolorbox}
\end{tcolorbox}
}
\makeatother
\parindent=0pt
%\newcommand{\cornell}[2]{%
%}
%\AddEverypageHook{
%\hspace{.3\textwidth}\vrule width 3pt depth .4\textheight
%\vspace{-\textheight}}
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
\makeindex
\begin{document}
\maketitle
\SetBgContents{\rule[0em]{4pt}{\textheight}}
\cornell{\index{Research question}Research question}{\lipsum*[2]}
\cornell{Another research question}{\lipsum*[5]}
\cornell[A fancy very important question]{Thi is easy to write?}{Even without \LyX{}, is not too hard fill this template, but you must compile twice.}
\cornell{Another research question very long for one line.}{\lipsum*[1]}
\cornell{\index{Fill much more}Do you want fill much more than a page}{No problem. \lipsum*[3]}
\cornell{More?}{No problem. \lipsum*[3-4]}
\cornell[Last question]{This is the end?}{Yes.}
\printindex
\end{document}

\indexing stuff (\usepackage{makeidx}\makeindex,\printindexas well as the odd\indexin the boxes) and everything worked as expected. – moewe Oct 15 '15 at 15:42\index{...}command works for me within\cornell{...}--> the index is there! – Oct 15 '15 at 16:09\index, but a common mistake is to assume that\indexdisplays its argument in addition to indexing it, whereas in fact it just indexes the argument without displaying it so if you've done\cornell{\index{stuff}}{...}then the text box will be empty. You need to do\cornell{stuff\index{stuff}}{...}– Nicola Talbot Oct 15 '15 at 16:28