是否可以打印页码,其中\newglossaryentry
打印特定词汇表条目描述(用 定义)(包glossaries
)?
梅威瑟:
\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{g:a}{name=A,description=\lipsum}
\newglossaryentry{g:b}{name=B,description=\lipsum}
\begin{document}
Glossary entry \gls{g:b} description is printed on page: X (I dont' know, how to print the page number).
\glsaddall
\printglossary[type=main]
\end{document}
答案1
以下是旧版本,这里是链接并引用描述页面版本:
我在手册中找不到glossaries-user
如何获取放置描述的页面引用的方法。想法是使用稍微修改过的glossarystyle
,这里派生自list
(实际上是标准)并添加\label{glo:page:##1}
,其中##1
扩展到词汇表键。
辅助命令\descpageref{key}
将显示排版描述的页面。
笔记:这假设唯一的键,即来自另一个键的同名键glossary
将导致相同的标签。
\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage[savenumberlist=true]{glossaries}
\makeglossaries
\newglossaryentry{g:a}{name=A,description=\lipsum}
\newglossaryentry{g:b}{name=B,description=\lipsum}
\let\origglspostdescription\glspostdescription
\newglossarystyle{mystyle}{%
\setglossarystyle{list}% base this style on the list style
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}\phantomsection\label{glo:page:##1}% Make a page label here
\glstarget{##1}{\glossentryname{##1}}]
\glossentrydesc{##1}\glspostdescription\space ##2}
}
\newcommand{\descpageref}[2][glo:page:]{%
\pageref{#1#2}
}
\begin{document}
Glossary entry \gls{g:b} is printed on page: \descpageref{g:b} and the other one is on page \descpageref{g:a}
\glsaddall
\printglossary[type=main,style=mystyle]
\end{document}
这是我几天前提供的代码的变体,定义了一个\newglossary
,但这并不重要。
可以与savenumberlist=true
选项一起使用该命令,该命令\glsdisplaynumberlist
显示使用某个条目的所有情况。(此处词汇表的详细信息并不重要,它们与格式无关\glsdisplaynumberlist
)
\documentclass{book}
\usepackage{hyperref}
\usepackage[savenumberlist=true,nomain]{glossaries}
\newglossary[aul]{authordict}{aus}{aug}{Dictionary of Authors}
\makeglossaries
\glsaddkey{birthyear}{\glsentrytext{\glslabel}}{\glsentrybirthyear}{\GLsentrybirthyear}{\glsbirthyear}{\Glsbirthyear}{\GLSbirthyear}
\glsaddkey{deathyear}{}{\glsentrydeathyear}{\GLsentrydeathyear}{\glsdeathyear}{\Glsdeathyear}{\GLSdeathyear}
\newglossarystyle{mystyle}{%
\setglossarystyle{list}% base this style on the list style
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}\myitemdelimiter}]
\glossentrydesc{##1}\glspostdescription\space ##2}
}
\newglossaryentry{Maxwell}{%
name={James Clerk Maxwell},
birthyear={1831},
deathyear={1869},
description={English physicist},
type=authordict,
}
\newglossaryentry{Boltzmann}{%
name={Ludwig Boltzmann},
birthyear={1844},
deathyear={1906},
description={Austrian physicist},
type=authordict
}
\newglossaryentry{Einstein}{%
name={Albert Einstein},
birthyear={1879},
deathyear={1955},
description={German physicist},
type=authordict
}
\defglsentryfmt[authordict]{\glsentryname{\glslabel} (\glsentrybirthyear{\glslabel} -- \glsentrydeathyear{\glslabel}), \glsentrydesc{\glslabel}}
\begin{document}
The Maxwell\footnote{\gls{Maxwell}}-
Boltzmann\footnote{\gls{Boltzmann}}
model.
\clearpage
Einstein\footnote{\gls{Einstein}}
-Bose-Condensate versus \gls{Maxwell}
Entry \glsentryname{Maxwell} is on page(s) \glsdisplaynumberlist{Maxwell}
\printglossary[type=authordict]
\end{document}
编辑这是 OP MWE 的版本
\documentclass{book}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage[savenumberlist=true]{glossaries}
\makeglossaries
\newglossaryentry{g:a}{name=A,description=\lipsum}
\newglossaryentry{g:b}{name=B,description=\lipsum}
\begin{document}
Glossary entry \gls{g:b} is printed on page: \glsdisplaynumberlist{g:b} (i dunno how to print the page).
\glsaddall
\printglossary[type=main]
\end{document}