Pageref、索引、词汇表?多种植物物种列表

Pageref、索引、词汇表?多种植物物种列表

我需要列出书中所有物种的植物清单。该清单必须以不同的顺序重复两次:

  1. 按通用名称的字母顺序排列,结构如下:通用名称,物种名称、页码;
  2. 按物种名称的字母顺序排列,结构如下:物种名称、通用名称、页码;

这是我对imakeidx(MWE)的尝试,可能比较笨拙,但我愿意接受建议,因为这是一本大书(700页),最好从一开始就找到最顺畅的方式:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{imakeidx}
\makeindex [name=com-sp,title=List of plants mentioned in text by comon name]
\makeindex [name=sp-com,title=List of plants mentioned in text by species name]

\begin{document}

\section{Text}

Here you can plant para grass\index[com-sp]{Para grass, \textit{Brachiaria mutica}}\index[sp-com]{\textit{Brachiaria mutica}, Para Grass}, and then\textit{Abelmosphus esculentus}\index[com-sp]{Okra, \textit{Abelmosphus esculentus}}\index[sp-com]{\textit{Abelmosphus esculentus}, Okra}


\lipsum[1-6]

Here you can plant para grass\index[com-sp]{Para grass, \textit{Brachiaria mutica}}\index[sp-com]{\textit{Brachiaria mutica}, Para Grass}, and then\textit{Abelmosphus esculentus}\index[com-sp]{Okra, \textit{Abelmosphus esculentus}}\index[sp-com]{\textit{Abelmosphus esculentus}, Okra}

\printindex [com-sp]
\printindex [sp-com]

\end{document}

按通用名称列出 按物种名称列出


旧问题是:

我需要列出出现特定标签的所有页码(用逗号分隔)。

我知道这只\pageref给出一个页码并且\label应该是唯一的,但我找不到任何其他方法。

在 MWE 中,我应该得到

胡芦巴 1,3

\documentclass{article}
\usepackage{lipsum}


\begin{document}

\section{Text}

Trigonella \label{001}

\lipsum[1-12]



Trigonella\label{001}

\lipsum[1-6]



\section{List of plants}

trigonella \pageref{001} 


\end{document}

答案1

这是使用glossaries-extrabib2gls.bib. 每种植物类型都使用 来定义在文件中@dualentry。例如plants.bib

% Encoding: UTF-8

@dualentry{paragrass,
 name={para grass},
 description={Brachiaria mutica}
}

@dualentry{okra,
 name={okra},
 description={Abelmosphus esculentus}
}

文档来源:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\usepackage[record,% use bib2gls
 nomain,% don't create 'main' glossary
 nostyles,% don't load default styles
 stylemods={mcols},% patch styles and load glossary-mcols.sty
 style=mcolindex,% set default style
 postpunc=comma% put a comma after the description
]{glossaries-extra}

\newglossary*{common}{List of Plants (by Common Name)}
\newglossary*{species}{List of Plants (by Species Name)}

\GlsXtrLoadResources[
  src={plants}, % terms defined in plants.bib
  type={common}, % put primary terms in the 'common' glossary
  dual-type={species}, % put dual terms in the 'species' glossary
  category={common}, % assign category for primary terms
  dual-category={species}, % assign category for dual terms
  combine-dual-locations=both % combine primary and dual locations
]

% provide convenient command to access dual entries
% (\species[options]{label}[insert] behaves like \gls[options]{dual.label}[insert])    
\glsxtrnewgls{dual.}{\species}

% provide semantic formatting command    
\newcommand{\speciesfmt}[1]{\emph{#1}}

% formatting attributes:
\glssetcategoryattribute{common}{glossdescfont}{speciesfmt}
\glssetcategoryattribute{species}{glossnamefont}{speciesfmt}
\glssetcategoryattribute{species}{textformat}{speciesfmt}

% case-changing attributes (adjusts glossary style):
\glssetcategoryattribute{common}{glossname}{firstuc}
\glssetcategoryattribute{common}{glossdesc}{firstuc}
\glssetcategoryattribute{species}{glossname}{firstuc}
\glssetcategoryattribute{species}{glossdesc}{firstuc}

% minor adjustments to the tree-like styles:

% don't use bold for the name in the glossary 
\renewcommand*{\glstreenamefmt}[1]{#1}

% put a comma and space before the description
\renewcommand{\glstreepredesc}{,\space}

\begin{document}
\section{Text}

Here you can plant \gls{paragrass}, and then \species{okra}.

\lipsum[1-6]

Here you can plant \gls{paragrass}, and then \species{okra}.

\printunsrtglossaries

\end{document}

通用名称使用 引用(和索引)\gls,物种使用 引用(和索引)\species。(标签不能包含空格或特殊字符。)包含引用的行显示为:

您可以在这里种植菊科植物,然后种植黄秋葵。

两个词汇表如下所示:

植物列表(按通用名称) 黄秋葵,Abelmosphus esculentus,1,2 臂形草,1,2 植物列表(按物种名称) 黄秋葵,Abelmosphus esculentus,1,2 臂形草,1,2

如果调用文档文件myDoc.tex那么构建过程如下:

pdflatex myDoc
bib2gls myDoc
pdflatex myDoc

如果您想要字母组,您需要添加-g--groupbib2gls调用并将样式更改为mcolindexgroup

答案2

glossaries我发现 这是一种更方便的替代方法。

该方法不是\index在文档中每次出现一个植物时使用两个命令,而是创建一个具有两种显示样式的独特词汇表(\gls在文档中使用非常方便)

“name” 字段用于通用名称 “description” 字段用于物种名称

使用\makenoidxglossaries允许混合使用排序方法,如所述用户手册

词汇表条目按物种名称的字母顺序定义,因此可以使用此顺序sort=def设置\printnoidxglossary

双株植物清单

\documentclass{article}


\usepackage{hyperref}
\usepackage[nomain, nogroupskip]{glossaries}


\newglossary{plants}{pli}{plo}{Plants}


\makenoidxglossaries

\newglossaryentry{001}{%
  type=plants,
  name={Okra},
  description={Abelmosphus esculentus},
}

\newglossaryentry{002}{%
  type=plants,
  name={Para grass},
  description={Brachiaria mutica},
}




% First Glossary style (common name, species name
\newglossarystyle{com-sp}{%
 \setglossarystyle{index}
 \renewcommand*{\glossentry}[2]{%
   \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}%
   ,\space \textit{\glossentrydesc{##1}},\space##2 \par
 }%
}


% Second Glossary style (species name, common name)
\newglossarystyle{sp-com}{%
 \setglossarystyle{index}%
 \renewcommand*{\glossentry}[2]{%
   \glsentryitem{##1}\textit{\glstarget{##1}{\glossentrydesc{##1}}}%
   ,\space \glossentryname{##1},\space##2 \par
 }%
}



\usepackage{blindtext}

\usepackage{pgffor}

\begin{document}



\foreach \x in {1,...,10} {%

\gls{001}% Mention okra here

\blindtext[10]

\gls{002}% Mention para grass here

\clearpage

}



\setglossarystyle{com-sp}
\printnoidxglossary[type=plants, sort=word,title=List of plants mentioned in text by common name]
\setglossarystyle{sp-com}
\printnoidxglossary[type=plants, sort=def,title=List of plants mentioned in text by species name]


\end{document}

相关内容