我可以轻松地使用 tcolorbox 创建列表,但是:
是否可以将定理描述(“注释”)放入索引中?
tcolorbox 有方法吗?
% arara: pdflatex
% arara: pdflatex
\documentclass{scrartcl}
\usepackage[most]{tcolorbox}
\tcbset{
commonstyle/.style={
theorem style=plain, % no break after title
fonttitle=\bfseries,
%fontupper=\itshape, % in “body”
separator sign none,
description delimiters parenthesis,
description font=\normalfont,
terminator sign={.\hspace{1em}},
% Box-Einstellungen
enhanced,arc=0mm,outer arc=0mm,
boxrule=0mm,toprule=0mm,bottomrule=0mm,left=0mm,right=0mm,
titlerule=0mm,toptitle=0mm,bottomtitle=0mm,top=0mm,
colback=white,coltitle=black,
%
boxsep=0pt, bottom=0pt, left=3pt, %
},
leftbar/.style={colframe=black, leftrule=1.75pt},
}
\newtcbtheorem[number within=section, list inside={mylist}]{defi}{Definition}{commonstyle}{def}
\newtcbtheorem[use counter from=defi, list inside={mylist}]{thm}{Theorem}{commonstyle, leftbar}{th}
\usepackage{lipsum} % Dummy-Text
\begin{document}
\section{Theorems with tcolorbox}
\lipsum[66]
\begin{thm}[]{A Theorem}{label2}
\lipsum[66]
\end{thm}
\begin{defi}[]{A Definitition}{label1}
\lipsum[66]
\end{defi}
\begin{thm}[]{Theorem of Pythagoras}{label3}
$$a^2+b^2=c^2$$
\end{thm}
\tcblistof[\section*]{mylist}{List of Theorems and Definitions, but no alphabetical Index}
\end{document}
答案1
我创建了一个解决方案xparse
:
% arara: pdflatex
% arara: makeindex
% arara: pdflatex
\documentclass{scrartcl}
\usepackage{makeidx}
\makeindex
\usepackage{xparse}
\usepackage[most]{tcolorbox}
% Theorems with automatical Index
%
% \newtcbtheoremautoindex[<init options>]{<name>}{<display name>}{<options>}{<prefix (label)>}
%
% <Description> to Index
% \begin{defi}[<Options>]{<Description>}{<label>} <content>\end{defi}
%
% <Description> not to Index
% \begin{defi}*[<Options>]{<Description>}{<label>} <content>\end{defi}
%
% Not labeled and not listed in lists of theorems, no Index:
% \begin{defi*}[<Options>]{<Description>} <content> \end{defi*}
%
\NewDocumentCommand\newtcbtheoremautoindex{ O{} m m m m }{%%
\newtcbtheorem[#1]{#2inner}{#3}{#4}{#5}%
\NewDocumentEnvironment { #2 } { s O{} m m }
{\IfBooleanTF{##1}
{\begin{#2inner}[##2]{##3}{##4}}% not to index
{\begin{#2inner}[##2, index={##3}]{##3}{##4}}% to index
} {\end{#2inner}}
% starred version (not labeled and not listed in lists of theorems):
\NewDocumentEnvironment { #2* } { O{} m }
{\begin{#2inner*}[##1]{##2}}% (and no index as well)
{\end{#2inner*}}
}%%
\newtcbtheoremautoindex[]{defi}{Definition}{}{def}
\begin{document}
\section{The three kinds of indexing}
\begin{defi}{\texttt{\textbackslash begin\{defi\}}~\dots~ \texttt{\textbackslash end\{defi\}}}{}
To index.
\end{defi}
\begin{defi}*{\texttt{\textbackslash begin\{defi\}*}~\dots~ \texttt{\textbackslash end\{defi\}}}{}
Not to index.
\end{defi}
\begin{defi*}{\texttt{\textbackslash begin\{defi*\}}~\dots~ \texttt{\textbackslash end\{defi*\}}}
As written in the manual: not labeled and not listed in lists of theorems, and no index as well.
\end{defi*}
\begin{defi}[colback=red]{Another Definitition to Index}{}
Using the optional argument.
\end{defi}
\printindex
\end{document}
答案2
如果要使用glossaries-extra
索引:
% Übersetzung (wegen Umlauten besser ‘lualatex’):
% arara: lualatex
% arara: lualatex
% arara: makeglossaries
% arara: bib2gls
% arara: lualatex
% arara: lualatex
% arara: clean: { extensions: [acn, acr,alg, aux, glg, glo, gls, ist, out, slg, syg, syi, toc, idx, ind, log, ilg, glstex, gz ] }
% Allgemeine Liste von Wörtern, die -sofern verwendet \gls{...}- im Index auftauchen:
\begin{filecontents*}[overwrite]{\jobname-index.bib}
@comment{Bei gleich immer Klammern: ={....} }
@index{Wort}
@index{geschrieben,alias={schreiben}}
@index{Abkuerzung,name={Abkürzung},text={Abkürzung}}
@index{Wert, plural={Werte}}
\end{filecontents*}
\documentclass[paper=a4]{scrartcl}
\usepackage{lipsum} % Dummy-Text
\usepackage{xparse}
\usepackage[most]{tcolorbox}
% tcolobox styles
\tcbset{
commonstyle/.style={
theorem style=plain, % no break after title
%theorem style=break, % break after title
fonttitle=\bfseries,
%fontupper=\itshape, % in “body”
separator sign none,
description delimiters parenthesis,
description font=\normalfont,
terminator sign={.\hspace{1em}},
% Box-Einstellungen
enhanced,arc=0mm,outer arc=0mm,
boxrule=0mm,toprule=0mm,bottomrule=0mm,left=0mm,right=0mm,
titlerule=0mm,toptitle=0mm,bottomtitle=0mm,top=0mm,
colback=white,coltitle=black,
%
boxsep=0pt, bottom=0pt,
before skip=0.75\baselineskip, % Theorem-Umgebungen 3/4 Leerzeile
after skip=0.75\baselineskip, % absetzen
},
leftbar/.style={colframe=black, left=4pt, leftrule=1.75pt},
}
% Theorems
\newtcbtheorem[number within=none]{bsp}{Beispiel}{commonstyle,
colback=lightgray!33, boxsep=4pt,
terminator sign colon}{bsp}
% Theorems with automatical Index
\newwrite\myoutfile
\immediate\openout\myoutfile=\jobname-autoindex.bib
\immediate\write\myoutfile{@comment{Theorem descriptions to index}} % schreiben der Datei sicherstellen
%
\newcounter{autoindexcounter}
%
\NewDocumentCommand\newtcbtheoremautoglossaries{ O{} m m m m }{%%
\newtcbtheorem[#1]{#2inner}{#3}{#4}{#5}%
\NewDocumentEnvironment { #2 } { s O{} m m O{##3}}
{\IfBooleanTF{##1}
{\begin{#2inner}[##2]{##3}{##4}}% not to bib
{
\stepcounter{autoindexcounter}
\IfNoValueTF{##5}
{\immediate\write\myoutfile{@index{autoindexcounter\theautoindexcounter, name={##3}}}%
}
{\immediate\write\myoutfile{@index{autoindexcounter\theautoindexcounter, name={##5},text={##3}}}%
}
\begin{#2inner}[##2]{##3}{##4}%
\glslink{autoindexcounter\theautoindexcounter}{}%
}%
}% to bib
{\end{#2inner}}
% starred version (not labeled and not listed in lists of theorems):
\NewDocumentEnvironment { #2* } { O{} m }
{\begin{#2inner*}[##1]{##2}}% (and no index as well)
{\end{#2inner*}}
}%%
\newtcbtheoremautoglossaries[number within=section, list inside={mylist}]{defi}{Definition}{commonstyle}{def}
\newtcbtheoremautoglossaries[use counter from=defiinner, list inside={mylist}]{satz}{Satz}{commonstyle, leftbar}{thm}
% Glossaries =================================
\usepackage[
colorlinks=true, % zur Hervorhebung
pdfborder={0 0 0},
]{hyperref}% Vor glossaries-extra laden!
%\usepackage[ngerman]{translator}
%Paket laden
%\usepackage{makeidx}
\usepackage[%
record={alsoindex},
index,
stylemods={bookindex},
style=altlistgroup,
shortcuts, % Abkürzungen für Befehle aktivieren
acronym, %ein Abkürzungsverzeichnis erstellen
toc, %Einträge im Inhaltsverzeichnis
section, %im Inhaltsverzeichnis auf section-Ebene erscheinen
]{glossaries-extra}
%\glssetcategoryattribute{acronym}{glossdescfont}{textit}
%\glssetcategoryattribute{acronym}{glossnamefont}{textsf}
\GlsXtrLoadResources[src={\jobname-index, \jobname-autoindex}, type=index,]
\usepackage{glossary-mcols} % mehrspaltige Verzeichnisse
\usepackage{glossary-longbooktabs} % Tabellenverzeichnisse
% Den Punkt am Ende jeder Beschreibung deaktivieren
\renewcommand*{\glspostdescription}{}
\makeglossaries
\begin{document}
\glsaddallunused % optional: auch ungenutze Einträge anzeigen
% \tableofcontents{}
\section{Theoreme mit tcolorbox, Index mit glossaries-extra}
\begin{satz}{Satz to Index}{}
\newline \ttfamily
\textbackslash begin\{satz\}[Optionen]\{Notiz\}\{th\}\\
\dots \\
\textbackslash end\{satz\}
\end{satz}
\begin{satz}{Satz to Index, aber anders im Index eingetragen}{}[anderer Eintrag im Index] \newline \ttfamily
\textbackslash begin\{satz\}[Optionen]\{Notiz hier\}\{th\}[Notiz im Index]\\
\dots \\
\textbackslash end\{satz\}
\end{satz}
\begin{satz}*{Satz not to Index}{} \newline \ttfamily
\textbackslash begin\{satz\}*[Optionen]\{Notiz\}\{th\}\\
\dots \\
\textbackslash end\{satz\}
\end{satz}
\begin{satz*}{Satz not labeled and not listed in lists of theorems, and no index as well} \newline \ttfamily
\textbackslash begin\{satz*\}[Optionen]\{Notiz\}\\
\dots \\
\textbackslash end\{satz*\}
\end{satz*}
\begin{bsp*}{Name des Beispiels}
Ein Indexeintrag: \gls{Wort}
\end{bsp*}
\begin{defi}{Eine Definition}{}
\lipsum[66]
\end{defi}
\begin{satz}{Ein Satz}{}
\lipsum[66]
\end{satz}
\lipsum[66]
\newpage
\begin{satz}[]{Satz des Pythagoras}{label3}
$$a^2+b^2=c^2$$
\end{satz}
\lipsum[66]
\tcblistof[\addsec]{mylist}{Liste der Sätze und Definition}
% Index ausgeben
\printunsrtglossary[type=index,style=bookindex,title=Stichwortverzeichnis]
\end{document}