我可以参考的语言学中的编号示例

我可以参考的语言学中的编号示例

我研究语言学,正在寻找一种方法来列举语言示例,以便我在文本中引用它们。

      (1) This is an example.

Sentence \ref{...} provides a good example of basic English.

如果可以与 一起使用\item,则可以获得加分,因为这使得它易于与 一起使用org-mode

答案1

有一些很好的软件包用于对语言学中的例子进行编号,它们是由语言学家专门设计的,以满足我们的需求。其中最常用的两个是gb4elinguex。评论中 egreg 链接的问题展示了一些示例。第三个软件包 ExPex 仍在开发中,功能极其强大,尽管其语法有点不像 LaTeX。下面是这三个软件包的示例,展示了它们的部分功能。在第一个示例中,显示了三个级别的示例嵌入。在第二个示例中,自动排列注释以便与非您正在撰写的文章语言的示例一起使用。我在这三个包中编写了相同的示例,以突出显示它们语法上的差异。

全面的评估

这三个软件包都可以非常快速地生成标准示例和注释。对于大多数用户,尤其是新用户,或gb4e都是linguex不错的选择。我个人更喜欢它gb4e,因为它使用 LaTeX 环境实现了示例的真正语义标记。然而,许多linguex用户更喜欢它,因为源输入更简单(因此根本不是语义的)。由于任何好的编辑器都可以自动插入代码块,所以这一直让我感到这是一个薄弱的论点。

如果您确实需要 ExPex 实现的定制程度,尤其是在处理复杂的注释系统时,我才会推荐它。有关其功能的一些示例,请参阅键入双语或三语对照文本做直行文本

格布

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{gb4e}
\begin{document}
\begin{exe}
\ex Wh/Quantifier Interactions\label{WHQ}
\begin{xlist}
\ex[]{What did everyone bring to the party?}
\begin{xlist}
\ex {Beer. \hfill \emph{Individual answer}}
\ex {Bill brought beer, Sue brought wine, Sam brought vodka \hfill \emph{Pair List answer}}
\ex {His favourite drink. \hfill \emph{Functional answer}}
\end{xlist}
\ex[]{Who brought every dish to the party?}
\begin{xlist}
\ex[]{Sue \hfill \emph{Individual answer}}
\ex[*]{Bill brought the salsa, Sue brought the hummus, \\ Sam brought the tabouli \hfill \emph{Pair list answer}}
\ex[*]{Its maker \hfill \emph{Functional answer}}
\end{xlist}
\end{xlist}
\end{exe}

As we can see in (\ref{WHQ}) there is a subject/object asymmetry in the availability of the Pair list and functional answers.

In example (\ref{citko21}) we can see some data from Polish.
\begin{exe}
\ex\label{citko21} 
\begin{xlist}
\ex[]{\gll Kogo     Jan lubi e      a Maria podziwia e?\\
           who.ACC Jan likes e.ACC and Maria admires e.ACC\\
       \trans `Who does Jan like and Maria admire?'}
\ex[*]{\gll Kogo/Komu Jan lubi e        a Maria ufa e?\\
            who.ACC/DAT Jan likes e.ACC and Maria trusts e.DAT\\
      \trans `Who does Jan like and Maria trust?'}
\end{xlist}
\end{exe}
\end{document}

gb4e 代码的输出

的优点和缺点

优点

  • 真实语义标记示例
  • 对语法判断有很好的支持
  • 自动排列光泽度(同上linguex
  • 使用标准\label\ref参考系统
  • 计数器很容易被操纵
  • 允许在数学模式_之外使用^

缺点

  • 难以自定义基本列表边距
  • 允许在数学模式_之外使用^

语言

另一个常用的语言示例包是linguex。以下是使用该包编写的相同示例。

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{linguex}
\begin{document}
\ex. Wh/Quantifier Interactions\label{WHQ}
    \a. What did everyone bring to the party?
        \a. Beer. \hfill \emph{Individual answer}
        \b. Bill brought beer, Sue brought wine, Sam brought vodka \hfill \emph{Pair List answer}
        \b. His favourite drink. \hfill \emph{Functional answer}
    \z.
    \b. Who brought every dish to the party?
        \a. Sue \hfill \emph{Individual answer}
        \b. *Bill brought the salsa, Sue brought the hummus, \\ Sam brought the tabouli \hfill \emph{Pair list answer}
        \b. *Its maker \hfill \emph{Functional answer}

As we can see in \ref{WHQ} there is a subject/object asymmetry in the availability of the Pair list and functional answers.

In example \ref{citko21} we can see some data from Polish.
\ex.\label{citko21} 
  \ag. Kogo     Jan lubi e      a Maria podziwia e?\\
           who.ACC Jan likes e.ACC and Maria admires e.ACC\\
       \trans `Who does Jan like and Maria admire?'
  \bg. *Kogo/Komu Jan lubi e        a Maria ufa e?\\
            who.ACC/DAT Jan likes e.ACC and Maria trusts e.DAT\\
      \trans `Who does Jan like and Maria trust?'

\end{document}

的优点和缺点

优点

  • 自动排列注释 (与 相同的代码gb4e)
  • 使用标准\label\ref参考系统
  • 不使用标签的下一个和上一个示例的简写
  • 简单的输入语法,通过上下文确定级别(以牺牲语义为代价)
  • 轻松定制基本列表边距

缺点

  • 标记不是语义的;上下文确定级别
  • 有些计数器是硬编码的,很难修改
  • 处理语法判断需要额外的代码来扩展
  • 注释示例的命令与非注释示例不同
  • 示例组必须用空行分隔
  • xcomment不能与允许选择性排除/包含环境的软件包一起使用

linguex 代码的输出

艾克斯

艾克斯软件包是一个功能极其强大的软件包,用于格式化示例和注释。它既可用于 Plain TeX,也可用于 LaTeX。它具有高度可定制性,并支持多级注释。它使用的语法更像 TeX,而不是 LaTeX(例如,基本示例环境使用\ex ... \xe而不是,\begin{ex} ... \end{ex}并使用基于 PSTricks 键值系统的语法实现自定义)。

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{expex}

% ExPex doesn't implement 3 levels of embedding, so this code is
% required for the first example
\def\beginsubsub{%
\par
\begingroup
\advance\leftskip by 2em
\def\b##1{\par\leavevmode\llap{\hbox to 2em{##1\hfil}}\ignorespaces}}
\def\endsubsub{\par\endgroup}

\gathertags % write tags to external tag file
\Lingset{everygla=\upshape} % make first gloss line upright
\begin{document}
\pex~ Wh/Quantifier Interactions\deftagex{WHQ}
\a {What did everyone bring to the party?}
\beginsubsub
  \b{i.} {Beer. \hfill \emph{Individual answer}}
  \b{ii.} {Bill brought beer, Sue brought wine, Sam brought vodka \hfill \emph{Pair List answer}}
  \b{iii.} {His favourite drink. \hfill \emph{Functional answer}}
\endsubsub
\a {Who brought every dish to the party?}
\beginsubsub
  \b{i.} Sue \hfill \emph{Individual answer}
  \b{ii.} {\ljudge{*}Bill brought the salsa, Sue brought the hummus, \\ Sam brought the tabouli \hfill \emph{Pair list answer}}
  \b{iii.} \ljudge{*}Its maker \hfill \emph{Functional answer}
\endsubsub
\xe
As we can see in (\getref{WHQ}) there is a subject/object asymmetry in the availability of the Pair list and functional answers.

In example (\getref{citko21}) we can see some data from Polish.
\pex<citko21> % an alternative syntax for tagging
\a
\begingl
  \gla Kogo     Jan lubi e      a Maria podziwia e?//
  \glb who.ACC Jan likes e.ACC and Maria admires e.ACC//
  \glft `Who does Jan like and Maria admire?'//
\endgl
\a
\begingl
  \gla Kogo/Komu Jan lubi e        a Maria ufa e?//
  \glb who.ACC/DAT Jan likes e.ACC and Maria trusts e.DAT//
  \glft `Who does Jan like and Maria trust?'//
\endgl
\xe
\end{document}

expex 代码的输出

的优点和缺点

优点

  • 使用键/值接口高度可定制
  • 支持多层次注释,格式非常丰富
  • 可与 Plain TeX 和 LaTeX 一起使用
  • 强大的参考和标签系统,但使用的方法不同于标准 LaTeX\label\ref系统
  • 用于语法判断的独立宏

缺点

  • 对于 LaTeX 用户来说,语法非常特殊(但对于 Plain TeX 用户来说则不然)
  • 学习曲线相当陡峭(71 页文档)
  • 仅两层自动嵌入

答案2

您可以将enumerate环境与常规label\ref组合一起使用:

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\setlist{label*=(\arabic*)}
\begin{document}
\lipsum[1]
\begin{enumerate}%%[label*=(\arabic*)]
  \item{This is an example \label{ex:basic}}
\end{enumerate}

\noindent Sentence~\ref{ex:basic} provides a good example of basic English. If you want to continue the numbering, you may use \verb|resume| feature provided by the \verb|enumitem| package.
%
\begin{enumerate}[resume]
  \item{This is an example \label{ex:advanced}}
\end{enumerate}

\noindent Sentence~\ref{ex:advanced} provides a good example of simple English. Hope this is useful.


\end{document}

在此处输入图片描述

enumerate如果中间还有其他东西,这将不起作用。resume将尝试从该点继续。要进行控制,您可以使用series以下选项enumitem

\documentclass{article}
\usepackage{lipsum}
%
\usepackage{enumitem}
%
\begin{document}
\lipsum[1]
\begin{enumerate}[label*=(\arabic*),leftmargin=1.5cm,series=example]
  \item{This is an example \label{ex:basic}}
\end{enumerate}

\noindent Sentence~\ref{ex:basic} provides a good example of basic English. If you want to continue the numbering, you may use \verb|resume| feature provided by the \verb|enumitem| package. Some other \verb|enumerate| in the middle:
%
\begin{enumerate}
  \item{This is an some other example not related to language \label{ex:other}}
\end{enumerate}
%
And again, one more language example.
\begin{enumerate}[label*=(\arabic*),leftmargin=1.5cm,resume*=example]
  \item{This is an example running very very very very very very very very very very very very very very very very very very very long into two lines  \label{ex:advanced}}
\end{enumerate}

\noindent Sentence~\ref{ex:advanced} provides a good example of simple English. Hope this is useful.


\end{document}

在此处输入图片描述

或者定义一个新列表:

\documentclass{article}
\usepackage{lipsum}
%
\usepackage{enumitem}
\newlist{example}{enumerate}{1}
\setlist[example]{label=(\arabic*),leftmargin=1.5cm}

\begin{document}
\lipsum[1]
\begin{example}
  \item{This is an example \label{ex:basic}}
\end{example}

\noindent Sentence~\ref{ex:basic} provides a good example of basic English. If you want to continue the numbering, you may use \verb|resume| feature provided by the \verb|enumitem| package. Some other \verb|enumerate| in the middle:
%
\begin{enumerate}
  \item{This is an some other example not related to language \label{ex:other}}
\end{enumerate}
%
And again, one more language example.
\begin{example}[resume*]
  \item{This is an example running very very very very very very very very very very very very very very very very very very very long into two lines  \label{ex:advanced}}
\end{example}

\noindent Sentence~\ref{ex:advanced} provides a good example of simple English. Hope this is useful.


\end{document}

答案3

sentence您可以基于原始list环境(环境itemizeenumerate基于list等)创建自己的环境。

我定义

  1. sentence一个可以容纳一个(编号的)句子的环境。宏\item被使用,但你不需要提供它,
  2. \oneSentence一个与环境一样工作的宏,以及
  3. nsentence一个可以容纳多个句子的环境(您也可以只将其用于一个句子,但必须\item明确插入)。

1. 和 2. 有一个可选参数,用作\label,您可以用 来引用\ref。在多句环境中,您必须使用\label(就像在 环境中一样enumerate)。

代码

\documentclass{article}
\newcounter{mySentence}                               % provides the number
\newcounter{myTempSentence}                           % is used for a resume-like style for nsentence
\renewcommand*{\themySentence}{(\arabic{mySentence})}               % (1), (2), (3), …
\newenvironment{sentence}[1][]{
     \begin{list}{\themySentence}{\refstepcounter{mySentence}}\item % \item already provided
     \ifnum\pdfstrcmp{#1}{}=0\else\label{#1}\fi                     % if opt label is provided, use it, otherwise do nothing (needs pdfLaTeX, solutions for other engines are available)
}{\end{list}}

\newenvironment{nsentence}{%
     \setcounter{myTempSentence}{\value{mySentence}} % save old value
     \addtocounter{myTempSentence}{-1}
     \begin{list}{\themySentence}{
         \usecounter{mySentence}
         \setcounter{mySentence}{\value{myTempSentence}}
         \refstepcounter{mySentence}
     }
}{\end{list}}

\newcommand*{\oneSentence}[2][]{\begin{sentence}[#1]#2\end{sentence}}

\begin{document}
Let's take a look at a sentence:
\begin{sentence}[myFirstSentence]
    This is an example.
\end{sentence}
Sentence~\ref{myFirstSentence} provides a good example of basic English.
    \oneSentence[thisIsALabel]{This works, too.}
After sentence~\ref{thisIsALabel} we look at a few more sentences.
\begin{nsentence}
    \item This is another example. \label{mySecondSentence}
    \item And this is a great sentence. \label{exampleForAdvancedEnglish}
\end{nsentence}
Sentences~\ref{mySecondSentence} and~\ref{exampleForAdvancedEnglish} are great examples for advanced English.
\end{document}

输出

输出

相关内容