# Removing automatic parentheses around references with linguex

When I use the \ref command, I automatically get parentheses around the cross-referenced number. I think it's because I'm using the linguex package for examples. I want to not have the parentheses show up automatically so that I can manually add subexample letters inside parentheses -- e.g. (5a) -- when the a wasn't ever part of a list that can be labeled. (Specifically, I need this to reference candidates in OT tableaux, which I make in tabular, which doesn't lend itself to list environments...as far as I can tell.)

Here's (what I hope is) a MWE:

\documentclass{article}

\usepackage{linguex}

\begin{document}

\ex. \label{test} Here's an example

I want to reference \ref{test} without getting parentheses around it automatically.

\end{document}


This outputs:

Since version 4 of linguex, the delimiters around the number in the example and in the references can be separately customized:

\documentclass{article}

\usepackage{linguex}
\renewcommand{\theExLBr}{}
\renewcommand{\theExRBr}{}

\begin{document}

\ex. \label{test} Here's an example

I want to reference \ref{test}

\end{document}


The default definition is of course

\newcommand{\theExLBr}{(}
\newcommand{\theExRBr}{)}


There are also \ExLBr and \ExRBr for the delimiters around the example number.

• how do I do this for selected examples without having to keep redefining theexlbr – Matías Guzmán Naranjo Jan 17 '17 at 18:30

Redefining \theExLbr and \theExRbr works "globally" by changing all occurrence of all labels. If you want to use \ref with parentheses most of the time and only need a one-off fix, you might consider editing the string returned by \ref. This requires xstring and refcount (the latter is also imported by hyperref).

\documentclass{article}
\usepackage{refcount, xstring}

\usepackage{linguex}
\newcommand{\myref}[2][]{%
\refused{#2}%
\StrSubstitute{\getrefnumber{#2}}{)}{#1)}%
}

\begin{document}

\ex.\label{sent1}
\a. Sentence 1
\b. Sentence 2

Sentences \myref[a,b]{sent1}

\end{document}