3

I write in Spanish and use theoremref package. I have a little problem with \thref package:

\documentclass{article}

\usepackage{theoremref,amsthm}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}

\theoremstyle{plain}

\newtheorem{teo}{Teorema}
\newtheorem{lem}{Lema}

\begin{document}

\begin{lem}[Exacto]
Lema exacto \thlabel{exact}
\end{lem}

\begin{lem}[Zorn]
Lema de Zorn\thlabel{zorn}
\end{lem}

\begin{teo}[Principal]
Teorema principal\thlabel{main}
\end{teo}

\thref{exact,zorn,main}

\end{document}

enter image description here

As you can see the command works fine, but there is a detail: the word and in the ref output (between lemma numbers and theorem). I'm writing in Spanish and this appears in English. How I can make the package theoremref, be translated?

PD: I bypassed this situation making \thnameref{exact}s \ref{exac} y \ref{zorn} but is not an ellegant way.

1 Answer 1

3

The "and" and the commas are hard-coded in package thmref. The following patches some internal commands to become more Spanish:

\documentclass{article}

\usepackage{theoremref,amsthm}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}

\theoremstyle{plain}

\newtheorem{teo}{Teorema}
\newtheorem{lem}{Lema}

\usepackage{etoolbox}

\begin{document}

\begin{lem}[Exacto]
Lema exacto \thlabel{exact}
\end{lem}

\begin{lem}[Zorn]
Lema de Zorn\thlabel{zorn}
\end{lem}

\begin{lem}[Foo]
Lema de Foo\thlabel{foo}
\end{lem}

\begin{teo}[Principal]
Teorema principal\thlabel{main}
\end{teo}

\subsubsection*{English, original version:}
\noindent
\thref{exact}\\
\thref{exact,zorn}\\
\thref{exact,zorn,foo}\\
\thref{exact,main}\\
\thref{exact,zorn,main}\\
\thref{exact,zorn,foo,main}

\makeatletter
\patchcmd\thmref@doref{and }{y }{}{%
  \errmessage{\noexpand\thmref@doref could not be patched}%
}
\patchcmd\thmref@doref{\ifthmref@final,\fi}{}{}{%
  \errmessage{\noexpand\thmref@doref could not be patched}%
}
\patchcmd\thmref@flush{, and}{\space y}{}{%
  \errmessage{\noexpand\thmref@flush could not be patched}%
}
\patchcmd\thmref@flush{\space and}{\space y}{}{%
  \errmessage{\noexpand\thmref@flush could not be patched}%
}
\makeatother

\subsubsection*{Spanish, patched version:}
\noindent
\thref{exact}\\
\thref{exact,zorn}\\
\thref{exact,zorn,foo}\\
\thref{exact,main}\\
\thref{exact,zorn,main}\\
\thref{exact,zorn,foo,main}

\end{document}

Result

Or as multi-language version:

\documentclass{article}

\usepackage{theoremref,amsthm}
\usepackage[english,spanish]{babel}
\usepackage[latin1]{inputenc}

\theoremstyle{plain}

\newtheorem{teo}{Teorema}
\newtheorem{lem}{Lema}

\usepackage{etoolbox}

\makeatletter
\newcommand*{\thmrefandtypename}{\space and\space}
\newcommand*{\thmreffinalcommaname}{,}
\newcommand*{\thmreffinaland}{, and}
\newcommand*{\thmreftwoand}{\space and}
\addto\captionsenglish{% 
  \renewcommand*{\thmrefandtypename}{\space and\space}%
  \renewcommand*{\thmreffinalcommaname}{,}%
  \renewcommand*{\thmreffinaland}{, and}%
  \renewcommand*{\thmreftwoand}{\space and}%
}
\addto\captionsspanish{%
  \renewcommand*{\thmrefandtypename}{\space y\space}%
  \renewcommand*{\thmreffinalcommaname}{}%
  \renewcommand*{\thmreffinaland}{\space y}%
  \renewcommand*{\thmreftwoand}{\space y}%
}
\patchcmd\thmref@doref{\space and }{\thmrefandtypename}{}{%
  \errmessage{\noexpand\thmref@doref could not be patched}%
}
\patchcmd\thmref@doref{\ifthmref@final,\fi}%
                      {\ifthmref@final\thmreffinalcommaname\fi}{}{%
  \errmessage{\noexpand\thmref@doref could not be patched}%
}
\patchcmd\thmref@flush{, and}{\thmreffinaland}{}{%
  \errmessage{\noexpand\thmref@flush could not be patched}%
}
\patchcmd\thmref@flush{\space and}{\thmreftwoand}{}{%
  \errmessage{\noexpand\thmref@flush could not be patched}%
}
\makeatother

\begin{document}

\begin{lem}[Exacto]
Lema exacto \thlabel{exact}
\end{lem}

\begin{lem}[Zorn]
Lema de Zorn\thlabel{zorn}
\end{lem}

\begin{lem}[Foo]
Lema de Foo\thlabel{foo}
\end{lem}

\begin{teo}[Principal]
Teorema principal\thlabel{main}
\end{teo}

\begin{otherlanguage}{english}
\subsubsection*{English, original version:}
\noindent
\thref{exact}\\
\thref{exact,zorn}\\
\thref{exact,zorn,foo}\\
\thref{exact,main}\\
\thref{exact,zorn,main}\\
\thref{exact,zorn,foo,main}
\end{otherlanguage}

\subsubsection*{Spanish, patched version:}
\noindent
\thref{exact}\\
\thref{exact,zorn}\\
\thref{exact,zorn,foo}\\
\thref{exact,main}\\
\thref{exact,zorn,main}\\
\thref{exact,zorn,foo,main}

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .