答案1
这里有一种方法可以做到这一点,其工作原理与相应的功能大致相同gb4e
。我们定义一个\exr
宏(无尾随.
),该宏以标签为参数,并使用该标签的引用作为示例编号。
\documentclass{article}
\usepackage{linguex}
\makeatletter
\newif\if@repeated\@repeatedfalse
\newcounter{savedExNo}
\renewcommand{\NormalEx}{\ifExWarning
\PackageWarning{linguex}{Check example numbering (screwed up?),
check number of empty lines at end of examples.
Detected}\fi\ExWarningtrue
\if@repeated
\Exformat[\ref{\tmp@ref}]
\setcounter{ExNo}{\value{savedExNo}}
\global\@repeatedfalse
\else
\if@noftnote\refstepcounter{ExNo}%
\Exformat[\ExLBr\Exarabic{ExNo}\ExRBr]%
\else
\refstepcounter{FnExNo}\Exformat[\FnExLBr\Exroman{FnExNo}\FnExRBr]%
\fi
\fi}
\newcommand{\exr}[1]{%
\@repeatedtrue
\setcounter{savedExNo}{\value{ExNo}}
\def\tmp@ref{#1}
\ex.}
\makeatother
\begin{document}
\ex. This is an example.
\ex. This example will be repeated.\label{r1}
\ex. \label{r2}
\a. An subexample.
\b. Another subexample.
\ex. Another example.
\exr{r1} This is the first repeated example.
\exr{r2}
\a. A repeated subexample.
\b. Another subexample.
\ex. Another example showing that the numbering continues correctly.
\ex. Another one.
\end{document}
答案2
那么重置计数器怎么样?
\documentclass{article}
\usepackage{linguex}
\def\exr{\setcounter{ExNo}{0}\ex}
\begin{document}
\ex. Some text\par
\ex. Some text\par
\exr. Some text\par
\ex. Some text\par
\end{document}
答案3
还有简单的\label
-\ref
系统与可选示例标签 ( \ex.[]
) 相结合,\label
位于点后面,并\ref
放在方括号中。这里还说明了子示例。
\documentclass{article}
\usepackage{linguex}
\begin{document}
\ex. Some text
\ex. Some text
\ex.\label{ex:aa} Some text (example number to be remembered: \ref{ex:aa})
\ex. Some text
\a. sub-ex
\b.\label{ex:cc} sub-ex (a sub-example number to be remembered: \ref{ex:cc})
\ex. Some text
\ex.[\ref{ex:aa}] Some text (repeated example number: \ref{ex:aa})
\ex. Some text
\ex.[\ref{ex:cc}] Some text (with the remembered sub-example number: \ref{ex:cc})
\end{document}