我正在创建一个论文模板
我在制作索引时遇到的问题是我想要生成如下所示的索引页:
Index
P
Picard, 2
W
Warp factor, 11
相关代码来自序言.tex看起来像这样:
\usepackage{imakeidx} % Package for creating index
% Activate hyperlinks for the index
\makeindex[columns=2, title=Index, intoc=true]
\index{Picard}
\index{Warp Factor}
索引最终打印在主文本作为:
% Index
\clearpage
\phantomsection % To correct the anchor toc index to the index page. Otherwise, the toc index takes user to the last section of the appendix chapter before this.
\printindex % Print the index
任何解决方案都将不胜感激。
编辑 - 2024 年 3 月 16 日晚上 9 点(欧洲中部时间):
更新的 MWE:
主文件的位置是src/main.tex
:
\documentclass[12pt]{book}
\input{src/contents/latex_doc_preamble/preamble.tex}
\begin{document}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\part{Part 1}
\chapter{Chapter 01}
\section{section 1}
\paragraph*{}
\blindtext \index{Picard} Picard.
\chapter{Chapter 02}
\section{section 1}
\paragraph*{}
\blindtext \index{Warp Factor} Warp Factor.
\appendix
\chapter{Appendix title}
\section{section 1}
\subsection{}
\paragraph*{}
\blindtext
\clearpage
\phantomsection % To correct the anchor toc index
\printindex % Print the index
\end{document}
序言文件的位置是src/contents/latex_doc_preamble/preamble.tex
:
\title{MWE}
\author{Some Author}
\usepackage{blindtext} % Generates dummy text for testing purposes
\usepackage{imakeidx} % Package for creating index
% \makeindex[columns=2, title=Index, intoc=true]
\makeindex[columns=2, title=Index, intoc=true,options=-s myindexstyle]
\usepackage{tocbibind} % Include table of contents, list of figures, etc., in table of contents
\usepackage[hidelinks]{hyperref} % Enhancements for hyperlinks and cross-references
编译后的pdf文件位置将是并使用以下命令build/main.pdf
进行编译:latexmk
latexmk -pdf -output-directory=build src/main.tex
答案1
对于这张糟糕的图像,我们深表歉意,它是 Okular/KDE 最新版本的一个功能。
imakeidx
文档第 15-16 页:
\begin{filecontents}[overwrite]{myindexstyle.ist}
headings_flag 1
heading_prefix
"\\bigskip\\par\\penalty-50\\textbf{"
heading_suffix
"}\\\\[\\medskipamount]"
symhead_positive "Symbols"
symhead_negative "symbols"
numhead_positive "Numbers"
numhead_negative "numbers"
delim_0 ",\~"
\end{filecontents}
\documentclass[12pt]{book}
\title{MWE}
\author{Some Author}
\usepackage{blindtext} % Generates dummy text for testing purposes
\usepackage{imakeidx} % Package for creating index
\makeindex[columns=2, title=Index, intoc=true,options=-s myindexstyle]
\usepackage{tocbibind} % Include table of contents, list of figures, etc., in table of contents
\usepackage[hidelinks]{hyperref} % Enhancements for hyperlinks and cross-references
\begin{document}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\part{Part 1}
\chapter{Chapter 01}
\section{section 1}
\paragraph*{}
\blindtext \index{Picard} Picard.
\chapter{Chapter 02}
\section{section 1}
\paragraph*{}
\blindtext \index{Warp Factor} Warp Factor.
\appendix
\chapter{Appendix title}
\section{section 1}
\subsection{}
\paragraph*{}
\blindtext
\clearpage
\phantomsection % To correct the anchor toc index to the index page. Otherwise, the toc index takes user to the last section of the appendix chapter before this.
\printindex % Print the index
\end{document}