我使用西班牙语写作并使用theoremref
包。我对包有一点问题\thref
:
\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}
如您所见,该命令运行正常,但有一个细节:ref 输出中的单词and
(在引理数字和定理之间)。我用西班牙语写作,但这以英语显示。我如何翻译包 theoremref?
PD:我绕过了这种情况,\thnameref{exact}s \ref{exac} y \ref{zorn}
但这不是一个优雅的方法。
答案1
“and” 和逗号在包中是硬编码的thmref
。以下修补了一些内部命令,使其更符合西班牙语:
\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}
或者多语言版本:
\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}