我不太明白ist
格式化文件的措辞index
。
基于 这个帖子格式化ist
。
当我尝试将 bf 系列应用于索引中的第一级项目时,出现如下 MWE 中的错误。
<inserted text>
}
l.19 \end{theindex}
有什么东西坏了,我该如何修复呢?
平均能量损失
\RequirePackage{filecontents}
\begin{filecontents*}[overwrite]{MyStyle.ist}
delim_0 "\\IndexDotfill "
delim_1 "\\IndexDotfill "
headings_flag 1
heading_prefix " \\IndexHeading{"
heading_suffix "}\n"
% https://winnt.developpez.com/tutoriels/latex-index/
%Generates an error when adding these to get the item in bold
%item_0 "\n \\item \\bfseries{"
%item_x1 "}\\normalfont\n \\subitem "
\end{filecontents*}
\documentclass{book}
\usepackage{tikz}
% Setup for MyStyle.ist
%--------------------------------------
% Formatage de l'index avec Tikz
%--------------------------------------
\newcommand*{\IndexDotfill}{%
\nobreak\dotfill\ \nobreak
}
\renewcommand*{\indexspace}{%
\par
\vspace{25pt plus 6pt minus 4pt}%
}
\newcommand*{\IndexHeading}[1]{%
\tikz\node[
rounded corners=5pt,
draw=orange,
fill=orange!10,
line width=1pt,
inner sep=5pt,
align=center,
font=\sffamily\bfseries\large,
minimum width=\linewidth-\pgflinewidth,
] {#1};%
\nopagebreak
\par
\vspace{2mm}%
}
%--------------------------------------
\usepackage{imakeidx}
\makeindex[columns = 2, title =Index, options = -s MyStyle.ist]
\begin{document}
% Some empty pages for generating the index entries
\setcounter{page}{6}\index{Citation}\null\newpage
\index{Definitions}\null\newpage
\index{Examples!Equation and Text}\index{Corollaries}\null\newpage
\index{Examples!Paragraph of Text}\null\newpage
\printindex
\end{document}
答案1
您想要生成的{\bfseries...}
不是\bfseries{....
\RequirePackage{filecontents}
\begin{filecontents*}[overwrite]{MyStyle.ist}
delim_0 "}\\IndexDotfill "
delim_1 "\\IndexDotfill "
headings_flag 1
heading_prefix " \\IndexHeading{"
heading_suffix "}\n"
item_0 "\n \\item {\\bfseries "
item_x1 "}\n \\subitem "
\end{filecontents*}
\documentclass{book}
\usepackage{tikz}
% Setup for MyStyle.ist
%--------------------------------------
% Formatage de l'index avec Tikz
%--------------------------------------
\newcommand*{\IndexDotfill}{%
\nobreak\dotfill\ \nobreak
}
\renewcommand*{\indexspace}{%
\par
\vspace{25pt plus 6pt minus 4pt}%
}
\newcommand*{\IndexHeading}[1]{%
\tikz\node[
rounded corners=5pt,
draw=orange,
fill=orange!10,
line width=1pt,
inner sep=5pt,
align=center,
font=\sffamily\bfseries\large,
minimum width=\linewidth-\pgflinewidth,
] {#1};%
\nopagebreak
\par
\vspace{2mm}%
}
%--------------------------------------
\usepackage{imakeidx}
\makeindex[columns = 2, title =Index, options = -s MyStyle.ist]
\begin{document}
% Some empty pages for generating the index entries
\setcounter{page}{6}\index{Citation}\null\newpage
\index{Definitions}\null\newpage
\index{Examples!Equation and Text}\index{Corollaries}\null\newpage
\index{Examples!Paragraph of Text}\null\newpage
\printindex
\end{document}