LyXTheorems, lemmas, definitions... in Spanish

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

Theorems, lemmas, definitions... in Spanish

Post by mikesol »

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,

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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)

Code: Select all

% Preview source code

%% LyX 1.6.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,oneside,english,spanish]{book}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3.5cm,rmargin=3cm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{color}
\usepackage{verbatim}
\usepackage{textcomp}
\usepackage{amsthm}
\usepackage{relsize}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{amssymb}
\onehalfspacing

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\DeclareRobustCommand{\lyxmathsym}[1]{\ifmmode\begingroup\def\b@ld{bold}
  \def\rmorbf##1{\ifx\math@version\b@ld\textbf{##1}\else\textrm{##1}\fi}
  \mathchoice{\hbox{\rmorbf{#1}}}{\hbox{\rmorbf{#1}}}
  {\hbox{\smaller[2]\rmorbf{#1}}}{\hbox{\smaller[3]\rmorbf{#1}}}
  \endgroup\else#1\fi}

%% A simple dot to overcome graphicx limitations
\newcommand{\lyxdot}{.}

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Paquetes
\usepackage[Glenn]{fncychap}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}
\usepackage{babelbib}
\usepackage{fancyhdr}


%%%%%%%%%%%%%
%% Encabezados
%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhead{}
\fancyhead[CE]{\scriptsize \leftmark}
\fancyhead[CO]{\scriptsize \rightmark}
\fancyhead[LE,RO]{\thepage}
\fancyfoot{}
\renewcommand{\headrulewidth}{0.9pt}
%%%%%%%%%%%%%
%% Estilos de teoremas
% \swapnumbers
 %\theoremstyle{plain}
%\newtheorem{teorema}{Teorema}%[section]
% \theoremstyle{definition}
% \newtheorem{definicion}[teorema]{Definici\'{o}n}
% \newtheorem{ejemplo}[teorema]{Ejemplo}
% \newtheorem{ejercicio}[teorema]{Ejercicio}
% \newtheorem{nota}[teorema]{$ $Nota}
% %\newtheorem*{sol}{Soluci\'{o}n}
% \newcommand{\bsol}{\begin{proof}[Soluci\'{o}n]}
% \newcommand{\esol}{\end{proof}}
% \theoremstyle{remark}
%% Fin Estilos

\renewcommand{\chaptername}{Capítulo}

\makeatother

\usepackage[spanish]{babel}
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
Could someone help me?

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Re: Theorems, lemmas, definitions... in Spanish

Post by mikesol »

Any idea???
iscm
Posts: 1
Joined: Mon May 04, 2009 5:54 pm

Re: Theorems, lemmas, definitions... in Spanish

Post by iscm »

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

Thanks in advance
20100
Posts: 3
Joined: Wed May 13, 2009 5:09 pm

Re: Theorems, lemmas, definitions... in Spanish

Post by 20100 »

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.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Theorems, lemmas, definitions... in Spanish

Post by Juanjo »

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

Code: Select all

\theoremstyle{plain}
\newtheorem{cor}[thm]{Corollary}
and, in the body,

Code: Select all

\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:

Code: Select all

\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:

Code: Select all

\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:

Code: Select all

\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

Re: Theorems, lemmas, definitions... in Spanish

Post by 20100 »

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 :)
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Theorems, lemmas, definitions... in Spanish

Post by Juanjo »

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

Theorems, lemmas, definitions... in Spanish

Post by ferminfm »

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

Code: Select all

\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):

Code: Select all

\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

Theorems, lemmas, definitions... in Spanish

Post by AndrOn »

I think this is outdated: you can now find an option in document->Parameters in section Language, and choose from here
Post Reply