
toc、lof、lot のようなリストを作成したいのですが、listofsongs などと呼ばれるべきでしょうか。質問は、同様のリストを作成できるパッケージはありますか、それともすべて自分で行う必要があるのでしょうか。
LaTeX で既に使用されているファイル拡張子のリストはありますか? たとえば、MyDocument.toc は tableofcontents と競合するため使用しないでください。
\listofsongs
最終的には、私が書いたように書くことができ\tableofcontents
、同様に動作するはずです。
答え1
おそらく LaTeX2e-kernel-macros\@starttoc
とを使用できるでしょう\addtocontents{<file-extension>}{<tokens>}
。
\addtocontents
<tokens>
LaTeX 実行の最後に aux ファイルが処理されるときに、そのファイルが入力用に開かれている場合に備えて、ファイルに未展開で書き込むためのいくつかのディレクティブを aux ファイルに (未展開で)\jobname.<file-extension>
書き込みます。
\@starttoc{<file-extension>}
ファイルが存在する場合はTeX にそのファイルを読み取り/処理させ\jobname.<file-extension>
、その後そのファイルを破棄して新たに作成し、入力用に開きます。これにより、LaTeX 実行の最後に aux ファイルが処理されるときに、そのファイルが入力用に開かれます。
もっと凝ったことをしたい場合は、\addcontentsline
LaTeX2e カーネルの -macro を参照してください。
基本的に、LaTeX 実行の最後に aux ファイルが処理されるときにそのファイルが入力用に開かれている場合、\addcontentsline{<file-extension>}{<command name>}{<tokens>}
トークン シーケンスを\contentsline{<command name>}{<tokens>}{<page number>}
ファイルに展開せずに書き込むためのいくつかのディレクティブが aux ファイルに書き込まれます。LaTeX実行の最後に aux ファイルを処理中に書き込んだ後、その中にそのディレクティブが見つかります 。したがって、そのディレクティブは、ファイルが読み取られたり処理されたりするときに実行されます。\jobname.<file-extension>
\jobname.<file-extension>
\contentsline{<command name>}{<tokens>}{<page number>}
\@starttoc
\jobname.<file-extension>
\contentsline{<command name>}{<tokens>}{<page number>}
は、 -argument と-argument\l@<command name>
という 2 つの引数を処理するマクロを呼び出します。<tokens>
<page number>
このメカニズムを toc-file および sectioning-commands とともに使用すると、または の<command name>
ような内容になり、マクロの実行が生成されますが、独自のルビ化カテゴリ用に独自の -macro を定義することもできます。section
subsection
\l@section
\l@subsection
\l@..
\addtocontents...
-メカニズム\@starttoc{<file-extension>}
は、他のものの下で制御シーケンスを定義します\tf@<file-extension>
。したがって、そのメカニズムが\write
ファイルを書き込むためのハンドルをすでに割り当てているかどうかを確認するには、制御シーケンスがすでに定義されているかどうかを確認するために - マクロを\jobname.<file-extension>
使用できます。\@ifundefined
\tf@<file-extension>
ただし、これは scrwfile パッケージが使用されていない場合にのみ機能します。ちなみに、ドキュメント内に toc、lof、lot などのリストを多数作成する予定の場合は、scrwfile パッケージが役立つかもしれません。このパッケージの詳細については、CTAN を参照してください。https://www.ctan.org/pkg/scrwfile
LaTeX2eカーネルについては、source2e.pdfファイルで説明とコメントが書かれています。このファイルは、https://www.ctan.org/pkg/source2e-
メカニズムと、そのメカニズムを利用する - マクロについては、ファイル F ltsect.dtx → 59 セクション コマンド → 59.3 目次などのセクションで説明されています。\addtocontents
\@starttoc
\addcontentsline
\documentclass{article}
\usepackage{hyperref}
\usepackage{verbatim}
\makeatletter
\newcommand\l@songline[2]{%
\par Now we have data about another song:\\
Title of song: #1. Song is printed on page: #2.%
}%
\makeatother
\begin{document}
\LaTeX{} will now write directives to aux-file for writing the first
line into \jobname.weird. These directives will be carried out at
the end of the \LaTeX-run when the aux-file is read/processed in
case at that time the file \jobname.weird is open for writing to it.\\
\addtocontents{weird}{First line in file \jobname.weird.}%
\bigskip
This is what \jobname.weird looks like before calling \verb|\@starttoc|: \\
\verbatiminput{\jobname.weird}
\bigskip
This is how \verb|\l@songline| is defined:\\{%
\csname verbatim@font\endcsname\selectfont
\expandafter\meaning\csname l@songline\endcsname
}%
\bigskip
The file \jobname.weird is \csname @ifundefined\endcsname{tf@weird}{not}{already} allocated.
\bigskip
\LaTeX will now read/process \jobname.weird and then destroy that file
and create it anew and open it for writing. Thus at the end of the
\LaTeX-run, when the aux-file is read/processed, that file will be open
for writing to it:\bigskip
\csname @starttoc\endcsname{weird}%
\bigskip
The file \jobname.weird is \csname @ifundefined\endcsname{tf@weird}{not}{already} allocated.
\bigskip
\LaTeX{} will now write directives to aux-file for writing the second
line into \jobname.weird. These directives will be carried out at
the end of the \LaTeX-run when the aux-file is read/processed in
case at that time the file \jobname.weird is open for writing to it.\\
\addtocontents{weird}{Second line in file \jobname.weird.}%
\bigskip
Now two \verb|\addcontentsline|-entries for writing things to \jobname.weird
that need to be "rubrified" by means of applying the \verb|l@songgline|-macro.
\addcontentsline{weird}{songline}{Morning has broken}
\addcontentsline{weird}{songline}{Final Countdown}
\end{document}
答え2
残念ながら、質問には MWE がありません。そのため、あなたが本当にやりたいことがわかりません。あなたのプロフィールを読むと、 を使用していると思いますscrbook
。そこで、最新の KOMA スクリプトを必要とする提案があります。
\documentclass[listof=totoc,ngerman]{scrbook}[2016/06/14]% needs at least KOMA-Scritp version 3.21
\usepackage{babel}
\DeclareNewTOC[
type=song,
tocentryindent=0pt,
tocentrynumwidth=2.3em,
tocentrystyle=tocline,
tocentrylinefill=\hfill,
tocentryentryformat=\sffamily,
tocentrypagenumberformat=\sffamily
]{los}
\newcaptionname{ngerman}{\listsongname}{Liederverzeichnis}
\DeclareNewSectionCommand[
style=chapter,
level=0,
beforeskip=-1sp,
innerskip=0pt,
afterskip=\baselineskip,
font=\usekomafont{section},
prefixfont=\usekomafont{chapter},
pagestyle=plain
]{song}
\renewcommand\songformat{}
\renewcommand\addsongtocentry[2]{\addxcontentsline{los}{song}{#2}}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\addchap{Einleitung}
Text
\listofsongs
\song{Ein Liedtitel}
\end{document}
book
以下は標準クラスと KOMA パッケージを使用した別のバージョンです。ただし、コマンドや環境tocbasic
をどのように定義するかはわかりません。\song
song
\documentclass[ngerman]{book}
\usepackage{babel}
\usepackage{tocbasic}[2016/06/14]% needs at least KOMA-Scritp version 3.21
\DeclareNewTOC[
type=song,
tocentryindent=0pt,
tocentrynumwidth=2.3em,
tocentrystyle=tocline,
tocentrylinefill=\hfill,
tocentryentryformat=\sffamily,
tocentrypagenumberformat=\sffamily
]{los}
\newcaptionname{ngerman}{\listsongname}{Liederverzeichnis}
\usepackage{lipsum}
\usepackage{hyperref}
\begin{document}
\listofsongs
\clearpage
\phantomsection\addxcontentsline{los}{song}{Ein Liedtitel im Verzeichnis}
\section*{Ein Liedtitel}
\lipsum
\clearpage
\phantomsection\addxcontentsline{los}{song}{Ein anderer Liedtitel im Verzeichnis}
\section*{Ein anderer Liedtitel}
\end{document}