![TeXMaker 上的 MakeIndex(首次使用者)](https://linux22.com/image/295086/TeXMaker%20%E4%B8%8A%E7%9A%84%20MakeIndex%EF%BC%88%E9%A6%96%E6%AC%A1%E4%BD%BF%E7%94%A8%E8%80%85%EF%BC%89.png)
我在网上查找了如何在 LaTeX 上创建索引,老实说,我不知道为什么没有好的文档。这让我想起了当时我试图学习如何创建参考书目(在 BibTeX 上),我花了至少 3 天时间才弄清楚,因为文档记录不全在线的。
无论如何,这是我的 MWE:
\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath, amssymb, enumitem}
\usepackage [english]{babel}
\usepackage{icomma} %no space after commas
\usepackage{imakeidx}%for indexes
\makeindex%for indexes
\setlength{\parindent}{0pt}
\newcommand{\E}{\text{E}}
\newcommand{\Var}{\text{Var}}
\begin{document}
\textbf{Notation}. We write $\mu^{\prime}_{k} = \E\left[X^{k}\right]$, known as the \textbf{$k$th raw moment}\index{raw moment} and $\mu_{k} = \E\left[\left(X-\mu\right)^{k}\right]$, known as the \textbf{$k$th central moment}\index{central moment}.
\printindex
\end{document}
我运行了 LaTeX -> MakeIndex -> PDFLaTeX,效果很好。但通常情况下,我在序言中会包含更多内容:
\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath, amssymb, enumitem}
\usepackage [english]{babel}
\usepackage[utf8]{inputenc}
\usepackage [autostyle, english = american]{csquotes}
\usepackage{icomma} %no space after commas
\usepackage{imakeidx}%for indexes
\makeindex%for indexes
\MakeOuterQuote{"}
\setlength{\parindent}{0pt}
\pagenumbering{gobble} %remove page numbers
\frenchspacing %no space after periods
\usepackage{graphicx}
%put photo in same folder, do \includegraphics{"file name"}
\newcommand{\E}{\text{E}}
\newcommand{\Var}{\text{Var}}
\begin{document}
\textbf{Notation}. We write $\mu^{\prime}_{k} = \E\left[X^{k}\right]$, known as the \textbf{$k$th raw moment}\index{raw moment} and $\mu_{k} = \E\left[\left(X-\mu\right)^{k}\right]$, known as the \textbf{$k$th central moment}\index{central moment}.
\printindex
\end{document}
如果我运行 LaTeX -> MakeIndex -> PDFLaTeX,则无法生成索引。这是为什么?我猜想可能inputenc
与其他包之间存在冲突。
答案1
为了生成索引,LaTeX 需要页码。因此,您需要删除以下行
\pagenumbering{gobble} %remove page numbers
然后
\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath, amssymb, enumitem}
\usepackage [english]{babel}
\usepackage[utf8]{inputenc}
\usepackage [autostyle, english = american]{csquotes}
\usepackage{icomma} %no space after commas
\usepackage{imakeidx}%for indexes
\makeindex%for indexes
\MakeOuterQuote{"}
\setlength{\parindent}{0pt}
\frenchspacing %no space after periods
\usepackage{graphicx}
%put photo in same folder, do \includegraphics{"file name"}
\newcommand{\E}{\text{E}}
\newcommand{\Var}{\text{Var}}
\begin{document}
\textbf{Notation}. We write $\mu^{\prime}_{k} = \E\left[X^{k}\right]$, known as the \textbf{$k$th raw moment}\index{raw moment} and $\mu_{k} = \E\left[\left(X-\mu\right)^{k}\right]$, known as the \textbf{$k$th central moment}\index{central moment}.
\printindex
\end{document}
生产