我对 Latex 还很陌生,所以如果这是一个新手问题,请原谅。但是我在网上搜索过,找不到答案。
我正在尝试使用以下方法在 TeXShop(在 Mac 上)中编译我的文件,但我不确定如何操作(仅使用“Typeset”按钮是不够的)。有人能帮帮我吗?
(pdf)latex
makeglossaries
(pdf)latex
(pdf)latex
当我尝试使用提供的脚本编译文档时,它卡住了。这是我看到的屏幕截图:
答案1
您创建一个文件
#!/bin/sh
bfname=$(dirname "$1")/"`basename "$1" .tex`"
pdflatex --shell-escape "$1"
makeindex -s "$bfname".ist -t "$bfname".glg -o "$bfname".gls "$bfname".glo
pdflatex --shell-escape "$1"
pdflatex --shell-escape "$1"
glossaries.engine
你可以用类似下面的名称保存此文件
/Users/yourusername/Library/TeXShop/Engines
您还需要使脚本可执行:
转到终端:cd ~/Library/TeXShop/Engines
然后
chmod u+x glossaries.engine
使用您的引擎的名称。
然后你就可以用引擎词汇表进行编译了。在点击编译按钮之前,你需要在“排版”按钮附近的列表中选择引擎,我想是因为在法语中,我有一个“组合”按钮。
答案2
以下是修改Alain Matthes 的回答确定是否使用makeglossaries
( makeindex
/ xindy
) 或bib2gls
. 编辑glossaries.engine
文件以:
#!/bin/sh
bfname=${1%\.*}
pdflatex "$1"
if grep -q "glsxtr@resource" "$bfname.aux"; then
bib2gls --group "$bfname"
# hybrid
if grep -q "@istfilename" "$bfname.aux"; then
pdflatex "$1"
makeglossaries "$bfname"
fi
elif grep -q "@istfilename" "$bfname.aux"; then
makeglossaries "$bfname"
fi
pdflatex "$1"
这适用于以下所有文档:
\makenoidxglossaries
&\printnoidxglossary
:\documentclass{article} \usepackage[acronym,symbols]{glossaries} \makenoidxglossaries % define entry in default 'main' glossary: \newglossaryentry{sample}{name={sample},description={an example}} % define entry in 'acronym' glossary: \newacronym{ex}{EX}{example} % define entry in 'symbols' glossary: \newglossaryentry{fx}{name={\ensuremath{f(x)}}, sort={fx}, description={a function of $x$}, type=symbols } \begin{document} A \gls{sample} document with an \gls{ex} function \gls{fx}. \printnoidxglossary % default: type=main \printnoidxglossary[type=acronym] \printnoidxglossary[type=symbols] \end{document}
\makeglossaries
&\printglossary
和makeindex
:\documentclass{article} \usepackage[acronym,symbols]{glossaries} \makeglossaries % define entry in default 'main' glossary: \newglossaryentry{sample}{name={sample},description={an example}} % define entry in 'acronym' glossary: \newacronym{ex}{EX}{example} % define entry in 'symbols' glossary: \newglossaryentry{fx}{name={\ensuremath{f(x)}}, sort={fx}, description={a function of $x$}, type=symbols } \begin{document} A \gls{sample} document with an \gls{ex} function \gls{fx}. \printglossary % default: type=main \printglossary[type=acronym] \printglossary[type=symbols] \end{document}
\makeglossaries
&\printglossary
和xindy
:\documentclass{article} \usepackage[xindy,acronym,symbols]{glossaries} \makeglossaries % define entry in default 'main' glossary: \newglossaryentry{sample}{name={sample},description={an example}} % define entry in 'acronym' glossary: \newacronym{ex}{EX}{example} % define entry in 'symbols' glossary: \newglossaryentry{fx}{name={\ensuremath{f(x)}}, description={a function of $x$}, type=symbols } \begin{document} A \gls{sample} document with an \gls{ex} function \gls{fx}. \printglossary % default: type=main \printglossary[type=acronym] \printglossary[type=symbols] \end{document}
bib2gls
:\RequirePackage{filecontents} \begin{filecontents*}{terms.bib} @entry{sample, name = {sample}, description = {an example} } \end{filecontents*} \begin{filecontents*}{abbrvs.bib} @abbreviation{ex, short = {EX}, long = {example} } \end{filecontents*} \begin{filecontents*}{syms.bib} @symbol{fx, name = {\ensuremath{f(x)}}, description = {a function of $x$} } \end{filecontents*} \documentclass{article} \usepackage[record,abbreviations,symbols]{glossaries-extra} \GlsXtrLoadResources[src={terms,abbrvs}] \GlsXtrLoadResources[src={syms},type={symbols}] \begin{document} A \gls{sample} document with an \gls{ex} function \gls{fx}. \printunsrtglossary % default: type=main \printunsrtglossary[type=abbreviations] \printunsrtglossary[type=symbols] \end{document}
\printunsrtglossary
仅有的:\documentclass{article} \usepackage[abbreviations,symbols]{glossaries-extra} % define entry in default 'main' glossary: \newglossaryentry{sample}{name={sample},description={an example}} % define entry in 'abbreviations' glossary: \newabbreviation{ex}{EX}{example} % define entry in 'symbols' glossary: \glsxtrnewsymbol [description={a function of $x$}] {fx}{\ensuremath{f(x)}} \begin{document} A \gls{sample} document with an \gls{ex} function \gls{fx}. \printunsrtglossary % default: type=main \printunsrtglossary[type=abbreviations] \printunsrtglossary[type=symbols] \end{document}
混合
bib2gls
+makeglossaries
(例如,如果您有一种xindy
无法复制的自定义样式bib2gls
,但您希望方便地将条目定义存储在.bib
文件中):\RequirePackage{filecontents} \begin{filecontents*}{terms.bib} @entry{sample, name = {sample}, description = {an example} } \end{filecontents*} \begin{filecontents*}{abbrvs.bib} @abbreviation{ex, short = {EX}, long = {example} } \end{filecontents*} \begin{filecontents*}{syms.bib} @symbol{fx, name = {\ensuremath{f(x)}}, description = {a function of $x$} } \end{filecontents*} \documentclass{article} \usepackage[record=alsoindex,xindy,abbreviations,symbols]{glossaries-extra} \makeglossaries \GlsXtrLoadResources[src={terms,abbrvs},sort=none,save-locations=false] \GlsXtrLoadResources[src={syms},type={symbols},sort=none,save-locations=false] \begin{document} A \gls{sample} document with an \gls{ex} function \gls{fx}. \printglossary % default: type=main \printglossary[type=abbreviations] \printglossary[type=symbols] \end{document}