![康奈尔笔记与索引](https://linux22.com/image/321037/%E5%BA%B7%E5%A5%88%E5%B0%94%E7%AC%94%E8%AE%B0%E4%B8%8E%E7%B4%A2%E5%BC%95%20.png)
在康奈尔笔记 - 需要 Lyx 或乳胶溶液,我喜欢 Fran 的 Cornell 笔记模板。有人知道如何在红色和蓝色文本框中创建索引吗?我想使用命令\index{}
为我的笔记创建索引,但当我\index{}
在 Fran 的文本框中使用时,文本框是空的。
答案1
我从链接的问题中获取了代码并添加到框命令\index{some text}
中\cornell
。\index{}
单独使用当然会导致索引条目为空,什么都不显示!
在我看来,索引整个框文本而不是一些关键词并不是一个好主意,所以我避免提供包装器命令,例如\textforbox{foo}
wherefoo
既作为框内的文本出现,又作为索引条目出现。(这无论如何都需要更多设置,因为如果使用,\index
可能会有一个可选参数,而且语法也使其更加困难)imakeidx
subentry
\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}