# gb4e: A package specific \ref{}-definition

I use \usepackage{gb4e} to reference and to contiuously number my linguistic examples.

It works like this:

\documentclass{article}

\usepackage[ngerman]{babel}
\usepackage{gb4e}

\begin{document}

\section{Introduction} \label{intro}

\begin{exe}
\ex \label{a} asdf
\end{exe}

In \ref{a} \dots. In \ref{intro} \dots.

\end{document}


The output looks like this:

Ideally, the \ref{a} output of the exe environment would be displayed in brackets while references of other elements like \section will still be shown without brackets. So the output would look like this:

Is anyone there who can solve the problem globally?

Note: I try to avoid to add brackets manually and write (\ref{}) in the tex file.

• By "brackets" you mean parenthesis, right? – Sverre Nov 12 '14 at 18:09

Define a new command. Below I've called it \pref (short for parenthesis ref):

\documentclass{article}
\usepackage{gb4e}
\newcommand{\pref}[1]{(\ref{#1})}

\begin{document}
\section{Introduction} \label{intro}
\begin{exe}
\ex \label{a} asdf
\end{exe}
In \pref{a} \dots. In \ref{intro} \dots.
\end{document}


• To be fair, I've stolen this code from somewhere, but I don't remember where. Maybe here. – Sverre Nov 12 '14 at 18:14
• Sverre, thank you so much. The attempt is slightly more elegant than the (\ref{}) but it involves a lot of manual replacing still. I was hoping for a solution that will treat the ref{}differently in case it refers to the exe environment. – Philip Nov 13 '14 at 8:38
• @Philip How does it involve a lot of manual replacing? You still need to type \ref{...} when you want a reference, so I don't see how it's any harder to type \pref{}? If necessary, define it as \pef. Then it's exactly the same number of characters. – Sverre Nov 13 '14 at 11:52
• thank you for your comment. I would like to use the command for larger documents that are already existing. So in these documents it would be necessary to search for each \ref{} manually and replace it if it is a exe \ref{}. For future documents it doesnt mean manual adjustment. – Philip Nov 13 '14 at 13:40