2

When writing multi-language documents, if a theorem title has different name corresponding to different languages, then there are two ways to refer to them:

  1. Using the original name as it appeared. For example, if a theorem written in the English context titled "Theorem", then later even referencing in French context, it is still called "Theorem".

  2. Using the name corresponding to the current context. For example, if a theorem written in the English context titled "Theorem", and when later referencing in French context, it would called "Théorème".

In my package ProjLib, the first naming method is called originalref, and the later is called regionalref. They are achieved roughly by:

  1. originalref: define separate environments for different languages, for example theoremenglish, theoremfrench, each has its \crefname configured, and define the main environment to select the proper one corresponding to the context.

  2. regionalref: define only a single environment theorem, and define its \crefname to be \csname theoremname\languagename\endcsname and its plural from, where these names \theoremnameenglish, \theoremnamefrench are set in the language configure file.

While the regionalref mode works quite well, the originalref mode defines too many environments and set \crefnames for too many times, and thus is considerably slow.

As I am rewriting this package with expl3, I would like to take this chance to find a new way of implementing. For example, is there some way to record the value of \languagename as the label is set, and reflect them in the referencing text? (It's just a rough idea, I never figured it out how this would actually work)

Do you have any ideas? Thank you in advance for any suggestion ~


You can use this demo document to see the effect of these two mode (and to feel how slow the originalref mode is ;) ):

%! TEX program = xelatex
\documentclass[regionalref]{einfart}
% \documentclass[originalref]{einfart}

\usepackage{ProjLib}

\begin{document}

\UseLanguage{English}

Current language: \languagename

\begin{theorem}\label{thm1}
    In English.
\end{theorem}

\cref{thm1,thm2}


\vspace{2cm}
\UseLanguage{French}

Current language: \languagename

\begin{theorem}\label{thm2}
    In French.
\end{theorem}

\cref{thm1,thm2}

\end{document}

regionalref:

enter image description here

originalref:

enter image description here

1
  • I didn't try but with zref it seems possible to record the "current language" as a new (per-label) property. Feb 20, 2022 at 3:47

1 Answer 1

3

I'm not sure exactly how you want this to interact with cleveref, but I think you're looking for something like ltproperties (available as of the 2023/11/1 release). You can define a new property like

\NewProperty{language}{now}{english}{\languagename}

and capture properties with \RecordProperties{<label>}{<list of properties>} the same way you'd use \label, then reference the properties with \RefProperty{<label>}{<property>}. Here's your example with the above-defined language property:

\documentclass[regionalref]{einfart}
% \documentclass[originalref]{einfart}

\usepackage{ProjLib}

\NewProperty{language}{now}{english}{\languagename}

\begin{document}

\UseLanguage{English}

Current language: \languagename

\begin{theorem}\RecordProperties{thm1}{label,language}
    In English.
\end{theorem}


\vspace{2cm}
\UseLanguage{French}

Current language: \languagename

\begin{theorem}\RecordProperties{thm2}{label,language}
    In French.
\end{theorem}

\RefProperty{thm1}{label}\par
\RefProperty{thm1}{language}\par
\RefProperty{thm2}{label}\par
\RefProperty{thm2}{language}\par
\end{document}

props

1
  • Thank you for this! The question is quite old so my original approach in the package create-theorem was certainly not like this one. The new feature seems to simplify things a lot, I shall take a closer look when I have more time to see if it can be used to improve that package :)
    – Jinwen
    Nov 3, 2023 at 12:07

You must log in to answer this question.

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