我想创建一个索引,因为它可以在词汇表-用户.pdf。
精准目标:缩略语词汇表和索引,其中列出了所有缩略语(尽管只针对选定的页面)以及其他术语。索引的页码应为彩色,在两个平衡的列中右对齐,用圆点填充术语和页码之间的空隙。
当前尝试: 现在词汇表用于词汇表,我计划使用索引包xindy
和样式文件作为索引。
问题:虽然我不确定正确的样式定义,但undefined controlsequence \lettergroup
只要使用示例样式文件,就会收到错误消息
梅威瑟:
\documentclass{muthesis}
\usepackage[xindy]{imakeidx}
\makeindex[options={-M indexStyle}]
\usepackage{lipsum}
\begin{document}
ASd\index{asd}
\lipsum
\index{end}
\printindex
\end{document}
样式文件(基于makeidx.xdy
,xindy
注释掉刚引起警告/错误的行):
;; $Id: makeidx.xdy,v 1.1 1997/02/07 14:17:31 kehr Exp $
;;
;; This file implements the Output Style Specifiers for plain
;; makeindex (see manpage of makeindex 2.x) in conjuction with
;; TeX/LaTeX.
;;
;; The Input Style Specifiers of makeindex cannot de defined in a
;; `xindy' style file. Use an appropriate version of the program
;; `tex2xindy' which should be included with this distribution.
;;
;; Since `xindy' uses a different specification language than
;; makeindex and some of the command-line options of makeindex are now
;; only available as style-file commands, this file can only serve as
;; a template that produces the default-markup of makeindex. However,
;; it may be used as a starting point for further modification and
;; specialization.
;;
;; The following values are taken from the source of the makeindex
;; distribution (see file scanst.h and the manpage) for further
;; details.
;;
;; Define all attributes appearing in your document. Your attributes
;; are all encapsulators you use in your \index commands following the
;; vertical bar sign `|'. For example `foo' is the attribute in the
;; command \index{...|foo}. Here you specify the set of attributes
;; that appear in your document, the order in which they appear in the
;; index and which one superdes the other.
;;
;; Example: a) (define-attibutes (("default") ("bf") ("it")))
;; b) (define-attibutes (("bf" "default")))
;;
;; The initial command is (change it accordingly):
;; (define-attributes (("default")))
;; The description of the location-classes.
;; Add more location classes as needed.
;; (define-location-class "arabic-page-numbers" ("arabic-numbers"))
;; (define-location-class "roman-page-numbers" ("roman-numbers-lowercase"))
;; (define-location-class "Roman-page-numbers" ("roman-numbers-uppercase"))
;; (define-location-class "alpha-page-numbers" ("alpha"))
;; (define-location-class "Alpha-page-numbers" ("ALPHA"))
;; The most frequently used cross reference class "see". Add more, if
;; necessary.
;; (define-crossref-class "see")
;; (markup-crossref-list :open "\see{" :close "}{}" :class "see")
;; In makeindex: page_precedence <string> "rnaRA"
;; List all location classes appearing in your document.
(define-location-class-order ("roman-page-numbers"
"arabic-page-numbers"
"alpha-page-numbers"
"Roman-page-numbers"
"Alpha-page-numbers"
"see"))
;; preamble <string> "\\begin{theindex}\n"
;; postamble <string> "\n\n\\end{theindex}\n"
(markup-index :open "\begin{theindex}~n"
:close "~n~n\end{theindex}~n"
:tree)
;; These specifiers are not directly supported via a command-line
;; switch as in makeindex. Add the appropriate markup-commands into
;; the preamble.
;; setpage_prefix <string> "~n \setcounter{page}{"
;; setpage_suffix <string> "}~n"
;; group_skip <string> "~n~n \indexspace~n"
(markup-letter-group-list :sep "~n~n \indexspace~n")
;; The indexentries (item_<..> specifiers)
(markup-indexentry :open "~n \item " :depth 0)
(markup-indexentry :open "~n \subitem " :depth 1)
(markup-indexentry :open "~n \subsubitem " :depth 2)
;; Location-references
;; delim_0 <string> ", "
;; delim_1 <string> ", "
;; delim_2 <string> ", "
(markup-locclass-list :open ", " :sep ", ")
;; delim_n <string> ", "
(markup-locref-list :sep ", ")
;; delim_r <string> "--"
(markup-range :sep "--")
;; Here follow all letter-groups. The short-cut notation is used here.
(define-letter-groups
("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m"
"n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"))
;;
;; The sort-rules map all letters to their lowercase counterpart.
;;
(sort-rule "A" "a")
(sort-rule "B" "b")
(sort-rule "C" "c")
(sort-rule "D" "d")
(sort-rule "E" "e")
(sort-rule "F" "f")
(sort-rule "G" "g")
(sort-rule "H" "h")
(sort-rule "I" "i")
(sort-rule "J" "j")
(sort-rule "K" "k")
(sort-rule "L" "l")
(sort-rule "M" "m")
(sort-rule "N" "n")
(sort-rule "O" "o")
(sort-rule "P" "p")
(sort-rule "Q" "q")
(sort-rule "R" "r")
(sort-rule "S" "s")
(sort-rule "T" "t")
(sort-rule "U" "u")
(sort-rule "V" "v")
(sort-rule "W" "w")
(sort-rule "X" "x")
(sort-rule "Y" "y")
(sort-rule "Z" "z")
;; That's all ;-)
;; End
;; Local Variables:
;; mode: lisp
;; End:
理性/我尝试过的:由于我想要一个像用户指南中的索引,因此最好的解决方案是复制该方法。但是,当我尝试从源创建用户指南时,索引没有显示。我假设我必须texindy
使用特定参数运行(就像 glossaries-code.pdf 所需的那样),但找不到生成说明。此外,在我看来,索引代码固定在类中nctldoc
,我被迫使用该类muthesis
。由于作者glossaries
更喜欢使用外部索引包,我认为使用索引包是有意义的。此外,我不确定如何在首字母缩略词和索引词汇表中使用该术语。虽然有解决方案:使词汇表术语仅添加选定的页码,使用显式索引包似乎更直接。
我不在乎使用哪个索引包,目前我正在尝试imakeidx
使用xindy
样式文件。
答案1
索引的页码应为彩色的,并在两个平衡的列中右对齐,并用点填充术语和页码之间的间隙。
可以通过以下方式实现:
\RequirePackage{filecontents}
\begin{filecontents*}{indexStyle.xdy}
(markup-locclass-list :open "\dotfill " :sep "\dotfill ")
\end{filecontents*}
\documentclass{muthesis}
\usepackage[xindy]{imakeidx}
\usepackage[colorlinks]{hyperref}
\makeindex[options={-M indexStyle}]
\usepackage{lipsum}
\begin{document}
ASd\index{asd}
\lipsum
\index{end}
\printindex
\end{document}
该索引如下所示:
为了自动索引词汇表条目,您可以尝试使用indexname
和dualindex
属性。示例文件sample-autoindex.tex
提供glossaries-extra
使用此方法:
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{makeidx}
\usepackage[abbreviations,counter=chapter,nopostdot=false]{glossaries-extra}
\renewcommand*{\abbreviationsname}{List of Abbreviations}
\renewcommand*{\glossarypreamble}{\emph{Numbers refer to the
\textbf{chapter} where the entry was referenced.}}
\makeindex
\makeglossaries
% Automatically index the location of entry in the glossary
% for those entries that are in the "general" category:
\glssetcategoryattribute{general}{indexname}{textbf}
\glssetcategoryattribute{general}{dualindex}{true}
% Only index first use for the glossary location lists
% (doesn't affect the indexing from "dualindex" attribute):
%\glssetcategoryattribute{general}{indexonlyfirst}{true}
% Automatically index the location of entry in the glossary
% for those entries that are in the "abbreviation" category
% and use "textbf" as the encap:
\glssetcategoryattribute{abbreviation}{indexname}{textbf}
\glssetcategoryattribute{abbreviation}{dualindex}{true}
% Only index first use for the glossary location lists
% (doesn't affect the indexing from "dualindex" attribute):
%\glssetcategoryattribute{abbreviation}{indexonlyfirst}{true}
% Convert the first letter of the name to upper case in the
% glossary for general entries:
\glssetcategoryattribute{general}{glossname}{firstuc}
% Allow "format" key to override "dualindex" attribute.
\GlsXtrEnableIndexFormatOverride
% use first field instead of name field
\renewcommand*{\glsxtrautoindexentry}[1]{\string\glsentryfirst{#1}}
% use long form for the sort value, if provided:
\renewcommand*{\glsxtrautoindexassignsort}[2]{%
\ifglshaslong{#2}%
{\glsletentryfield{#1}{#2}{long}}%
{\glsletentryfield{#1}{#2}{sort}}%
}
% Define general entries:
\newglossaryentry{duck}{name=duck,%
description={a waterbird with webbed feet}}
\newglossaryentry{parrot}{name=parrot,%
description={mainly tropical bird with bright plumage}}
\newglossaryentry{at}{name={@},%
description={makeindex's default for the ``actual value''}}
\newglossaryentry{esc}{name={"},%
description={makeindex's default for the ``escape value''}}
\newglossaryentry{level}{name={!},%
description={makeindex's default for the ``level value''}}
\newglossaryentry{encap}{name={|},%
description={makeindex's default for the ``encap value''}}
% Set abbreviation style:
\setabbreviationstyle{long-short-sc}
% Define abbreviations:
\newabbreviation
{html}% identifying label
{html}% short form
{hypertext markup language}% long form
\newabbreviation
{xml}% identifying label
{xml}% short form
{extensible markup language}% long form
\title{Sample document testing the glossaries-extra package}
\author{Nicola Talbot}
\begin{document}
\maketitle
\chapter{Introduction}
This is a sample\index{sample} document testing the
\texttt{glossaries-extra} package.
\chapter{General Entries}
Sample entries: \gls{duck} and \gls{parrot}.
Test makeindex's special characters: \gls{at} (actual)
\gls{esc} (escape) \gls{level} (level) and \gls{encap} (encap).
\chapter{Abbreviations}
First use: \gls{html} and \gls{xml}.
Next use: \gls{html} and \gls{xml}.
\newpage
Uses some entries again: \gls{duck} and \gls[format=textit]{parrot}.
\printglossaries
\printindex
\end{document}
属性dualindex
是布尔值。如果true
那么每当使用类似命令引用条目时,\gls
它也会用 进行索引\index
。例如,\gls{duck}
另外还会\index{duck}
。如果indexonlyfirst
设置了属性(在上面注释掉),那么只有第一次使用\gls
(或变体)时才会伴随\index
。
如果设置了属性indexname
,则表示应使用 来索引该条目在词汇表中的位置\index
。此属性的值可以是true
(索引时不使用 encap) 或 encap 值。例如, 值textbf
表示当条目duck
出现在词汇表中时,应使用 来索引它\index{duck|textbf}
。由于词汇表在第一次运行 LaTeX 时并不存在,因此索引只有在词汇表存在之后才能完全创建,因此如果indexname
使用 ,则构建过程需要如下:
pdflatex sample-autoindex
makeglossaries sample-autoindex
pdflatex sample-autoindex
makeindex sample-autoindex
pdflatex sample-autoindex
实际使用的部分\index
来自\glsxtrautoindexentry{
标签}
默认情况下,它使用\glsentryname
来匹配术语在词汇表中的显示方式。在上文中,它被更改为使用\glsentryfirst
,这是术语首次使用时显示的方式。
中使用的排序部分\index
使用\glsxtrautoindexassignsort{
CS}{
标签}
, 在哪里CS是用于存储排序值的控制序列。在上面,我已将其重新定义为使用长格式(如果已设置)。这意味着缩写按其长格式排序。
该\gls
命令(及其变体)允许使用密钥更改词汇表中使用的默认封装format
。您可以使用以下命令确保此封装被复制\index
到
\GlsXtrEnableIndexFormatOverride
例如,使用此集合,\gls[format=textbf]{duck}
否则\index{duck|textbf}
它只会执行\index{duck}
。
完整文档如下:sample-autoindex.pdf
词汇表如下:
缩写列表:
索引:
如果你想使用hyperref
,请查看sample-autoindex-hyp
反而