## LaTeX forum ⇒ LyX ⇒ Theorems, lemmas, definitions... in Spanish

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
mikesol
Posts: 8
Joined: Sun Mar 22, 2009 8:42 am

### Theorems, lemmas, definitions... in Spanish

Hello guys,

I'm making my thesis in Lyx, and i need to write theorems, definitions, etc; but its necesary that appear like Teorema, Lema, Definición, etc.

I selected the document's language in spanish, the encoding is latin1, and the Theorems(AMS), Theorems(AMS-Extended) and Theorems(By Chapter).

The problems it's the definitions for the theorems still in Theorem, Definition, etc,

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.\theoremstyle{plain}\ifx\thechapter\undefined\newtheorem{thm}{Theorem}\else\newtheorem{thm}{Theorem}[chapter]\fi   \theoremstyle{definition}   \newtheorem{defn}[thm]{Definition}

The preamble is this, (copy-paste from the source view)


Could someone help me?

Tags:

mikesol
Posts: 8
Joined: Sun Mar 22, 2009 8:42 am
Any idea???

iscm
Posts: 1
Joined: Mon May 04, 2009 5:54 pm
I think I have the same problem but a bit funnier. In the screen I can see Teorema, Demostracion etc But when I export the document (or print to file) some of the keywords remain in english (theorem, definition, etc) while others get the correct translation (Demostracion instead proof) etc

That is driving me crazy. for I haven´t any idea about managing that

Could anyone help (I coarse grain solution patching files or something could help me

20100
Posts: 3
Joined: Wed May 13, 2009 5:09 pm
Hello I have more or less the same problem (except that it is in french and no solutions. Also my chapter are not named chapter but Chapitre...

So if someone has a solution ? I have tried to disable babel but it gave me some errors in converting to pdf.

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am
I am not a LyX user, but after playing a bit with this program, I think I may clarify some things. Suppose you want to write a corollary. You choose "Corollary" in the corresponding drop box (located at the top left corner, at least in my version of LyX). Then you see something like "Corolario xx.xx" in your document, depending on the document class, language settings, etc.. So you start typing the corollary statement. When you get the pdf file, you see "Corollary" (in English), independently of the language settings. What happened?

Internally, LyX adds to the preamble of the LaTeX source the lines
\theoremstyle{plain}\newtheorem{cor}[thm]{Corollary}

and, in the body,
\begin{cor}    text of the corollary you type\end{cor}

The label that appears in the pdf is fixed by the \newtheorem command, which defines the cor environment. You can't change the label (in English)... unless you redefine somehow the cor environment. For example, add to the preamble the following code:
\makeatletter\@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}\makeatother

That's magic! You now get "Corolario", as desired, in the pdf file. The same process must done for every theorem-like environment. But, which code should be used to make redefinitions? Let us write again the original source lines with some colors
\theoremstyle{plain}
\newtheorem{cor}[thm]{Corollary}

as well as the line needed for redefinition:
\@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}

Do you see the matching elements? Let's consider lemmas. LyX writes this in the preamble:
\theoremstyle{plain}
\newtheorem{lem}[thm]{Lemma}

so you should add this to the preamble:
\@namedef{lem}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Lema}}

There are also environments with the * suffix (unnumbered environments):
\theoremstyle{definition}
\newtheorem*{problem*}{Problem}

which can be changed by
\@namedef{problem*}{\@thm{\th@definition }{}{Problema}}

Don't forget to put together all the \@namedef commands between \makeatletter and \makeatother, as shown below, assuming that your document has theorems, corollaries, unnumbered propositions, unnumbered examples, exercises and unnumbered remarks:
\makeatletter\@namedef{thm}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Teorema}}\@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}\@namedef{prop*}{\@thm {\th@plain }{}{Proposici\'on}}\@namedef{example*}{\@thm {\th@definition }{}{Ejemplo}}\@namedef{xca}{\@thm{\let \thm@swap \@gobble \th@definition }{thm}{Ejercicio}}\@namedef{rem*}{\@thm {\th@remark }{}{Observaci\'on}}\makeatother

Compare with the lines written by LyX in the preamble:
\theoremstyle{plain}\newtheorem{thm}{Theorem}[section]\theoremstyle{plain}\newtheorem{cor}[thm]{Corollary}\theoremstyle{plain}\newtheorem*{prop*}{Proposition}\theoremstyle{definition}\newtheorem*{example*}{Example}\theoremstyle{definition}\newtheorem{xca}[thm]{Exercise}\theoremstyle{remark}\newtheorem*{rem*}{Remark}

Mikesol, before adding \usepackage commands, check if the corresponding package has been already loaded. For example, in your file, babel appears three times.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

20100
Posts: 3
Joined: Wed May 13, 2009 5:09 pm
Hello, I have finally found a solution.

You can select all your text (ctrl-A) and by a right clic you have a Text style option > personalize > language...

And now my whole document is under a single selectlanguage english

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am
20100 wrote:Hello, I have finally found a solution.

You can select all your text (ctrl-A) and by a right clic you have a Text style option > personalize > language...

And now my whole document is under a single selectlanguage english

That only inserts \selectlanguage commands in the LaTeX code, which have no influence on how theorem-like environments are labeled. So it does not solve the problem exposed in the opening post.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

ferminfm
Posts: 1
Joined: Mon Sep 13, 2010 7:39 am
Thanks Juanjo, your solution works for me... almost as is. I'm using Lyx 1.6.5 with babel on Ubuntu 10.04. The only thing I had to modify is to elimine the tag
\makeatother

at the end of the code you provided. Otherwise it wouldn't compile at all (lots of LaTeX errors). I also added fields to change the name of numbered propositions and definitions. At the end, my LaTeX preamble for my document looks like this (copy & paste):

\makeatletter\@namedef{thm}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Teorema}}\@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}\@namedef{defn}{\@thm{\let \thm@swap \@gobble \th@definition }{thm}{Definici\'on}}\@namedef{prop}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Proposici\'on}}\@namedef{prop*}{\@thm {\th@plain }{}{Proposici\'on}}\@namedef{example*}{\@thm {\th@definition }{}{Ejemplo}}\@namedef{xca}{\@thm{\let \thm@swap \@gobble \th@definition }{thm}{Ejercicio}}\@namedef{rem*}{\@thm {\th@remark }{}{Observaci\'on}}

I hope it helps anyone who ran into the same problem. Thanks again, this is a problem I had been dealing with for some time.

AndrOn
Posts: 1
Joined: Fri Dec 11, 2015 10:44 pm
I think this is outdated: you can now find an option in document->Parameters in section Language, and choose from here