如何自动获取单词旁边的页码

如何自动获取单词旁边的页码

我有一个单词文件。我使用了环境longtable。我想将其他单词的页码添加到某些单词中。

我不知道如何自动执行此操作,因为我可以更改页面格式或添加一些新词,然后我会更改位置词 - 我会更改页码。下表就是我的意思。

+--------+---------------+-----------------------------------------------+
| word_a | pronunciation | meaning, (the page number of the word word_g) |
| ...    | ...           | ...                                           |
| page 8                                                                 |
+--------+---------------+-----------------------------------------------+  
| ...    | ...           | ...                                           |
| page 9                                                                 |
+--------+---------------+-----------------------------------------------+
| word_g | pronunciation | meaning, (the page number of the word word_a),|
|        |               | (the page number of the word word_g)          |
| ...    | ...           | ...                                           |   
| page 10                                                                |
+--------+---------------+-----------------------------------------------+
| ...    | ...           | ...                                           | 
+--------+---------------+-----------------------------------------------+

平均能量损失

\documentclass[10pt,a5paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=slovak,english]{babel}
\usepackage[a5paper, top=15mm, left=10mm, right=10mm, bottom=10mm,foot=5mm,marginparsep=0mm]{geometry}
\usepackage{longtable}
\usepackage{tipa}
\usepackage{ wasysym}
\usepackage{ amssymb }

%skratky
%---
\newcommand*{\podm}{\textit{\small [noun]} }
\newcommand*{\pridm}{\textit{\small [adj]} }
\newcommand*{\zamen}{\textit{\small [pronoun]} }
\newcommand*{\pris}{\textit{\small [adverb]} }
\newcommand*{\cislo}{\textit{\small [number]} }
\newcommand*{\slo}{\textit{\small [verb]} }
\newcommand*{\pred}{\textit{\small [preposition]} }
\newcommand*{\spoj}{\textit{\small [conjunction]} }
\newcommand*{\cit}{\textit{\small [exclamation]} }
%---
\newcommand*{\jedc}{\textit{\small [singular]} }
\newcommand*{\mnoc}{\textit{\small [plural]} }
\newcommand*{\poc}{\textit{\small [C]} }
\newcommand*{\nep}{\textit{\small [U]} }
\newcommand*{\CU}{\textit{\small [C, U]} }
\newcommand*{\jed}{\textit{\small [S]} }
\newcommand*{\slot}{\textit{\small [T]} }
\newcommand*{\sloi}{\textit{\small [I]} }
\newcommand*{\ubn}{\textit{\small [usually before noun]} }
\newcommand*{\us}{\textit{\small [usually singular]} }
\newcommand*{\up}{\textit{\small [usually plural]} }
\newcommand*{\nbn}{\textit{\small [not before noun]} }
\newcommand*{\obn}{\textit{\small [only before noun]} }
\newcommand*{\bn}{\textit{\small [before noun]} }
\newcommand*{\nubn}{\textit{\small [not usually before noun]} } 
%---
\newcommand*{\UK}{{\small (UK) }}
\newcommand*{\US}{{\small (US) }}
\newcommand*{\SR}{{\small (SR) }}
%---
\newcommand*{\fone}{\fontfamily{qag}\selectfont} % Eng word
\newcommand*{\ftwo}{\fontfamily{phv}\selectfont} % pronunciation
\newcommand*{\fthree}{\fontfamily{ccr}\selectfont} %
\newcommand*{\ffour}{\fontfamily{pag}\selectfont} % 
%--
\newcommand*{\tm}{\small \fontfamily{ccr}\selectfont} % komentar
%---
\newcommand*{\frm}{\textit{\small (formal)} }
\newcommand*{\ifrm}{\textit{\small (informal)} }
\newcommand*{\app}{\textit{\small (approving)} } 
\newcommand*{\pc}{\textit{\small (computing)} }
\newcommand*{\osh}{\textit{\small (old-fashioned)} }
\newcommand*{\slg}{\textit{\small (slang)} }
\newcommand*{\mat}{\textit{\small (mathematics)} }
\newcommand*{\chem}{\textit{\small (chemistry)} }
\newcommand*{\lit}{\textit{\small (literary)} }
\newcommand*{\mus}{\textit{\small (music)} } 
\newcommand*{\fin}{\textit{\small (finance)} }
\newcommand*{\gem}{\textit{\small (geometry)} }
\newcommand*{\gmm}{\textit{\small (grammar)} } 
\newcommand*{\bus}{\textit{\small (business)} } 
\newcommand*{\law}{\textit{\small (law)} } 
\newcommand*{\phs}{\textit{\small (physics)} } 
\newcommand*{\frrm}{\textit{\small (rather formal)} }
\newcommand*{\irrm}{\textit{\small (rather informal)} }
\newcommand*{\sth}{\textit{\small sth }}
\newcommand*{\stb}{\textit{\small sb }}
\newcommand*{\tboo}{\textit{\small (taboo)} }
\newcommand*{\sla}{\textit{\small (slang)} }
\newcommand*{\odi}{\textit{\small (often disapproving)} }
\newcommand*{\bis}{\textit{\small (business)} }
\newcommand*{\diss}{\textit{\small (disapproving)} }
\newcommand*{\ling}{\textit{\small (linguistics)} }

\begin{document}
\catcode`\-=12
\sloppy

\begin{longtable}{llp{5cm}}
  {\fone lime } & {\ftwo [\textipa{laIm }] } & \podm \nep vápno $\square$ \CU limetka $\square$ \poc {\fone lime tree, linden tree } {\ftwo [\textipa{\textprimstress lIn.d@n }] } lipa \\
  {\fone avenue } & {\ftwo [\textipa{\textprimstress \ae [email protected]: }] } & \podm \poc avenue, alej, bulvár \textit{\tm (Ave., Av.)}  \\
  {\fone lane } & {\ftwo [\textipa{leIn }] } & \podm \poc poľná cesta $\square$ \poc jazdný pruh, dopravný pás \\
  {\fone grove } & {\ftwo [\textipa{gr@Uv }] } & \podm \poc háj, lesík \\

  %---
  \newpage
  %---

  {\fone ancient } & {\ftwo [\textipa{\textprimstress eIn.S\super @nt }] } & \pridm staroveký $\square$ starý, starobylý, starodávny $\square$ \mnoc {\fone the ancients } staroveké národy  \\
  {\fone navigation } & {\ftwo [\textipa{\textsecstress n\ae v. I\textprimstress geI.S\super @n }] } & \podm \nep navigácia $\square$ riadenie lode, let  \\
  {\fone sailor } & {\ftwo [\textipa{\textprimstress seI.l@\super r }] } & \podm \poc námorník, lodník $\square$    \\

  %---
  \newpage
  %---

  {\fone compass } & {\ftwo [\textipa{\textprimstress k2m.p@s }] } & \podm \poc kompas  \\
  {\fone approximate } & {\ftwo [\textipa{@\textprimstress pr6k.sI.m@t }] } & \pridm približný  \\
  {\fone exact$^{1000}$} & {\ftwo [\textipa{Ig\textprimstress z\ae kt }] } & \pridm presný, bezchybný, exaktný   \\ 
\end{longtable}


\end{document}

答案1

正如评论所述,使用glossaries可能是最佳解决方案。但是,如果您想保留原始方法,则可以使用label和的组合pageref,其中第二个将显示第一个的页码。

梅威瑟:

\documentclass{article}
\usepackage[a6paper,landscape]{geometry}
\usepackage{longtable}

\begin{document}
\begin{longtable}{|l|l|}
\hline
word a & meaning a (see also page \pageref{wordb})\\\hline
\newpage
\hline
word b\label{wordb} & meaning b\\\hline
\end{longtable}
\end{document}

结果:

在此处输入图片描述

相关内容