LaTeX forum ⇒ LyXTheorems, 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

Postby mikesol » Wed Apr 22, 2009 3:17 pm

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,

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
  2. \theoremstyle{plain}
  3. \ifx\thechapter\undefined
  4. \newtheorem{thm}{Theorem}
  5. \else
  6. \newtheorem{thm}{Theorem}[chapter]
  7. \fi
  8. \theoremstyle{definition}
  9. \newtheorem{defn}[thm]{Definition}


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

  1. % Preview source code
  2.  
  3. %% LyX 1.6.2 created this file. For more info, see http://www.lyx.org/.
  4. %% Do not edit unless you really know what you are doing.
  5. \documentclass[12pt,oneside,english,spanish]{book}
  6. \usepackage[T1]{fontenc}
  7. \usepackage[latin1]{inputenc}
  8. \usepackage[letterpaper]{geometry}
  9. \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3.5cm,rmargin=3cm}
  10. \setcounter{secnumdepth}{3}
  11. \setcounter{tocdepth}{3}
  12. \usepackage{color}
  13. \usepackage{verbatim}
  14. \usepackage{textcomp}
  15. \usepackage{amsthm}
  16. \usepackage{relsize}
  17. \usepackage{graphicx}
  18. \usepackage{setspace}
  19. \usepackage{amssymb}
  20. \onehalfspacing
  21.  
  22. \makeatletter
  23.  
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
  25. \DeclareRobustCommand{\lyxmathsym}[1]{\ifmmode\begingroup\def\b@ld{bold}
  26. \def\rmorbf##1{\ifx\math@version\b@ld\textbf{##1}\else\textrm{##1}\fi}
  27. \mathchoice{\hbox{\rmorbf{#1}}}{\hbox{\rmorbf{#1}}}
  28. {\hbox{\smaller[2]\rmorbf{#1}}}{\hbox{\smaller[3]\rmorbf{#1}}}
  29. \endgroup\else#1\fi}
  30.  
  31. %% A simple dot to overcome graphicx limitations
  32. \newcommand{\lyxdot}{.}
  33.  
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
  35. \theoremstyle{plain}
  36. \ifx\thechapter\undefined
  37. \newtheorem{thm}{Theorem}
  38. \else
  39. \newtheorem{thm}{Theorem}[chapter]
  40. \fi
  41. \theoremstyle{definition}
  42. \newtheorem{defn}[thm]{Definition}
  43.  
  44. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
  45. %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  46. %%%Paquetes
  47. \usepackage[Glenn]{fncychap}
  48. \usepackage{graphicx}
  49. \usepackage{amsmath}
  50. \usepackage[spanish]{babel}
  51. \usepackage[latin1]{inputenc}
  52. \usepackage{babelbib}
  53. \usepackage{fancyhdr}
  54.  
  55.  
  56. %%%%%%%%%%%%%
  57. %% Encabezados
  58. %%%%%%%%%%%%%
  59. \pagestyle{fancy}
  60. \fancyhead{}
  61. \fancyhead[CE]{\scriptsize \leftmark}
  62. \fancyhead[CO]{\scriptsize \rightmark}
  63. \fancyhead[LE,RO]{\thepage}
  64. \fancyfoot{}
  65. \renewcommand{\headrulewidth}{0.9pt}
  66. %%%%%%%%%%%%%
  67. %% Estilos de teoremas
  68. % \swapnumbers
  69. %\theoremstyle{plain}
  70. %\newtheorem{teorema}{Teorema}%[section]
  71. % \theoremstyle{definition}
  72. % \newtheorem{definicion}[teorema]{Definici\'{o}n}
  73. % \newtheorem{ejemplo}[teorema]{Ejemplo}
  74. % \newtheorem{ejercicio}[teorema]{Ejercicio}
  75. % \newtheorem{nota}[teorema]{$ $Nota}
  76. % %\newtheorem*{sol}{Soluci\'{o}n}
  77. % \newcommand{\bsol}{\begin{proof}[Soluci\'{o}n]}
  78. % \newcommand{\esol}{\end{proof}}
  79. % \theoremstyle{remark}
  80. %% Fin Estilos
  81.  
  82. \renewcommand{\chaptername}{Capítulo}
  83.  
  84. \makeatother
  85.  
  86. \usepackage[spanish]{babel}
  87. \addto\shorthandsspanish{\spanishdeactivate{~<>}}


Could someone help me?

Thanks in advance.

Tags:

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

Postby mikesol » Fri Apr 24, 2009 2:36 am

Any idea???

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

Postby iscm » Mon May 04, 2009 6:11 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

Thanks in advance

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

Postby 20100 » Wed May 13, 2009 5:12 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.

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Postby Juanjo » Fri May 15, 2009 12:59 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
  1. \theoremstyle{plain}
  2. \newtheorem{cor}[thm]{Corollary}

and, in the body,
  1. \begin{cor}
  2. text of the corollary you type
  3. \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:
  1. \makeatletter
  2. \@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}
  3. \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:
  1. \makeatletter
  2. \@namedef{thm}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Teorema}}
  3. \@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}
  4. \@namedef{prop*}{\@thm {\th@plain }{}{Proposici\'on}}
  5. \@namedef{example*}{\@thm {\th@definition }{}{Ejemplo}}
  6. \@namedef{xca}{\@thm{\let \thm@swap \@gobble \th@definition }{thm}{Ejercicio}}
  7. \@namedef{rem*}{\@thm {\th@remark }{}{Observaci\'on}}
  8. \makeatother

Compare with the lines written by LyX in the preamble:
  1. \theoremstyle{plain}
  2. \newtheorem{thm}{Theorem}[section]
  3. \theoremstyle{plain}
  4. \newtheorem{cor}[thm]{Corollary}
  5. \theoremstyle{plain}
  6. \newtheorem*{prop*}{Proposition}
  7. \theoremstyle{definition}
  8. \newtheorem*{example*}{Example}
  9. \theoremstyle{definition}
  10. \newtheorem{xca}[thm]{Exercise}
  11. \theoremstyle{remark}
  12. \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

Postby 20100 » Fri May 15, 2009 6:00 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 :)

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Postby Juanjo » Fri May 15, 2009 10:55 pm

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

Postby ferminfm » Mon Sep 13, 2010 7:48 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
  1. \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):

  1. \makeatletter
  2. \@namedef{thm}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Teorema}}
  3. \@namedef{cor}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Corolario}}
  4. \@namedef{defn}{\@thm{\let \thm@swap \@gobble \th@definition }{thm}{Definici\'on}}
  5. \@namedef{prop}{\@thm{\let \thm@swap \@gobble \th@plain }{thm}{Proposici\'on}}
  6. \@namedef{prop*}{\@thm {\th@plain }{}{Proposici\'on}}
  7. \@namedef{example*}{\@thm {\th@definition }{}{Ejemplo}}
  8. \@namedef{xca}{\@thm{\let \thm@swap \@gobble \th@definition }{thm}{Ejercicio}}
  9. \@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

Postby AndrOn » Fri Dec 11, 2015 10:48 pm

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


Return to “LyX”

Who is online

Users browsing this forum: No registered users and 6 guests