4

I am working with the linguex package for linguist examples/data. Now I would to have a number of sentences – each being their own example – and underneath I would like to have e.g. syntactic bracketing, with the numbers corresponding to the linguistic data from above BUT with an additional bar (or "prime") next to the number.

It should look like this:

(1) This is the first sentence.

(2) This is the second sentence.

Here I am talking a bit about the sentences (1) and (2).

(1') [syntactic structure for the first sentence]

(2') [syntactic structure for the second sentence]

\documentclass{article}
\usepackage{linguex}
\begin{document}

\ex. This is the first sentence. \label{S01}

\ex. This is the second sentence. \label{S02}

Here I am talking a bit about the sentences \ref{S01} and \ref{S02}.

% missing code

\ex.[\ref{S01}'] has the bar OUTside the brackets but I would like the
bar to be INside the brackets.

% \ex.[\ref{S01}$'$] gives me a similar result, except the bar looks 
% different (tilted), it's still not inside the brackets.

\end{document}

(1)' has the bar OUTside the brackets but I would like the bar to be INside the brackets.

Help with this will be much appreciated – thank you!

  • 1
    Welcome to TeX.SX! This is a really well written first question, thank you for asking it here. – moewe May 13 '18 at 14:18
3

You can do it with refcount and its expandable \getrefnumber command.

\documentclass{article}
\usepackage{linguex}
\usepackage{refcount}

\makeatletter
\newcommand{\Vref}[2]{% #1 is the label, #2 is the modifier
  \begingroup\edef\Vref@temp{\endgroup
    \noexpand\Vref@\getrefnumber{#1}(\getrefnumber{#1})\noexpand\@nil%
  }(\Vref@temp#2)%
}
\def\Vref@ #1(#2)#3\@nil{#2}
\makeatother

\begin{document}

\ex. This is the first sentence. \label{S01}

\ex. This is the second sentence. \label{S02}

Here I am talking a bit about the sentences \ref{S01} and \ref{S02}.

% missing code

\ex.[\Vref{S01}{'}] has the apostrophe inside the brackets

\ex.[\Vref{S01}{$'$}] has the prime inside the brackets

\end{document}

enter image description here

The reference is stored with the parentheses, so we want to remove them first and add them back later.

If \getrefnumber returns 0 (which happens if the label is not yet defined), the call would be

\Vref@ 0(0)\@nil

After the first run, the expansion of \getrefnumber{S01} would be (1), so the call is

\Vref@ (1)((1))\@nil

and the right path is taken in any case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.