2

How can I automatically enclose the \glt (\trans) line in gb4e's interlinear glosses in context-aware quotation marks with \enquote{} from csquotes?

\documentclass{article}
\usepackage[english]{babel}
\usepackage{gb4e}
\usepackage{csquotes}
\begin{document}
\begin{exe}
    \ex 
    \gll Etwas fremdsprachiger Text \\
         some {foreign language-y} text \\
    \glt \enquote{Free translation.}
\end{exe}
\end{document}

I want to be able to just type

\glt Free translation.

and have that rendered as

“Free translation.”

in the resulting PDF.

  • Will \glt always be the last entry within the exe environment? If you have such consistency, one could perhaps insert the \enquote upon usage of \glt. If not, provide us with a more comprehensive set of usages of \glt. – Werner Oct 29 '14 at 5:09
  • While \gll is pretty strict on its input (two lines delimited by \\), \glt accepts anything. Would you accept having to type \glt Free translation \\? – egreg Oct 29 '14 at 8:03
  • egreg: Yes, that would be OK, too. Werner: See the documentation for gb4e. – Jipí Oct 29 '14 at 17:24
2

You can redefine \glt to capture content up to some ending delimiter. Below I've used \end from \end{exe}:

enter image description here

\documentclass{article}
\usepackage[english]{babel}
\usepackage{gb4e}
\usepackage{csquotes}
\begin{document}
\begin{exe}
  \ex 
  \gll Etwas fremdsprachiger Text \\
       some {foreign language-y} text \\
  \glt \enquote{Free translation.}
\end{exe}

% Now redefine \glt to capture everything up to \end{exe}
\let\oldglt\glt
\long\def\glt #1 \end{\oldglt \enquote{#1}\end}

\begin{exe}
  \ex 
  \gll Etwas fremdsprachiger Text \\
       some {foreign language-y} text \\
  \glt Free translation.
\end{exe}

\end{document}

Depending on your use-case, other delimiters can also be used to capture the scope of the \enquote (like \\ - suggested in comment).

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.