LyXSeparate Counters for Theorems and Propositions

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
hiei1985
Posts: 1
Joined: Fri Jun 08, 2012 3:06 am

Separate Counters for Theorems and Propositions

Post by hiei1985 »

Hi everybody!

I'm using LyX in conjunction with the IEEEtran layout. I've noticed that there is a unique counter that keeps track of propositions, theorems and lemmas, e.g.:

Theorem 1 - Proposition 2 - Theorem 3 - Proposition 4

Is there a way to set a separate counter for each math structure? e.g.:

Theorem 1 - Proposition 1 - Theorem 2 - Proposition 2

Thanks!

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Separate Counters for Theorems and Propositions

Post by Stefan Kottwitz »

Hi,

welcome to the board!

Separate counters seem to be the default, as I can read in the IEEEtran documentation in XII. THEOREMS AND PROOFS. Perhaps show how you defined your theorem and proposion environment, the best would be posting a compilable Infominimal working example which shows the problem.

Stefan
LaTeX.org admin
sbahmani
Posts: 2
Joined: Wed Jun 13, 2012 6:08 pm

Separate Counters for Theorems and Propositions

Post by sbahmani »

Hi,

I'm having the same problem. The attached LyX file generates the following LaTeX code.

Code: Select all

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{IEEEtran}
\usepackage[latin9]{inputenc}
\usepackage{amsthm}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
\theoremstyle{plain}
\newtheorem{lem}[thm]{\protect\lemmaname}

\makeatother

\usepackage{babel}
\providecommand{\lemmaname}{Lemma}
\providecommand{\theoremname}{Theorem}

\begin{document}
\begin{lem}
This is a Lemma.\end{lem}
\begin{thm}
This is a Theorem.\end{thm}

\end{document}
I think the main problem is that the IEEEtran layout in LyX by default adds the thm counter to other similar math environments like lemma or corollary. For instance in the code above we have:

Code: Select all

\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
\theoremstyle{plain}
\newtheorem{lem}[thm]{\protect\lemmaname}
Is there anyway to fix this within LyX?
Attachments
test.lyx
(1.38 KiB) Downloaded 218 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Separate Counters for Theorems and Propositions

Post by Stefan Kottwitz »

I think IEEEtran.layout uses theorems.inc which you could find on your system or in the LyX SVN. There I can read, for example:

Code: Select all

Style Lemma
        CopyStyle             Theorem
        DependsOn             Theorem
        LatexName             lem
        LabelString           "Lemma \thetheorem."
        Preamble
                \theoremstyle{plain}
                \newtheorem{lem}[thm]{\protect\lemmaname}
        EndPreamble
        LangPreamble
                \providecommand{\lemmaname}{_(Lemma)}
        EndLangPreamble
        BabelPreamble
                \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}}
        EndBabelPreamble
End
You could change the style, alternatively you could make those definitions yourself in the preamble, as the LaTeX export shows but without the optional thm counter. For this, go to Document settings in LyX where you find an edit field for the preamble.

Stefan
LaTeX.org admin
sbahmani
Posts: 2
Joined: Wed Jun 13, 2012 6:08 pm

Separate Counters for Theorems and Propositions

Post by sbahmani »

Stefan_K wrote: You could change the style, alternatively you could make those definitions yourself in the preamble, as the LaTeX export shows but without the optional thm counter. For this, go to Document settings in LyX where you find an edit field for the preamble.
Thanks for your quick response Stefan. Actually, I already tried to redefine the lem environment in the preamble, but LyX cannot compile the PDF and says 'lem' is already defined. Below is the completer log. I think it has something to do with the \protect thing. I'm not familiar with the command, but I can guess it doesn't allow redefinition of the command.

Sohail

Code: Select all

This is pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8) (preloaded format=pdflatex 2011.5.12)  13 JUN 2012 13:32
entering extended mode
**newfile3.tex

(C:\Users\sbahmani\AppData\Local\Temp\lyx_tmpdir.Hp4480\lyx_tmpbuf7\newfile3.te
x
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2009-06-19, ngerman-x-2009-06-19, french, loaded.

("D:\Program Files (x86)\MikTeX 2.8\tex\latex\ieeetran\IEEEtran.cls"
Document Class: IEEEtran 2007/03/05 V1.7a by Michael Shell
-- See the "IEEEtran_HOWTO" manual for usage information.
-- http://www.michaelshell.org/tex/ieeetran/
\@IEEEtrantmpdimenA=\dimen102
\@IEEEtrantmpdimenB=\dimen103
\@IEEEtrantmpcountA=\count79
\@IEEEtrantmpcountB=\count80
\@IEEEtrantmptoksA=\toks14
LaTeX Font Info:    Try loading font information for OT1+ptm on input line 366.

("D:\Program Files (x86)\MikTeX 2.8\tex\latex\psnfss\ot1ptm.fd"
File: ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
)
-- Using 8.5in x 11in (letter) paper.
-- Using PDF output.
\@IEEEnormalsizeunitybaselineskip=\dimen104
-- This is a 10 point document.
\CLASSINFOnormalsizebaselineskip=\dimen105
\CLASSINFOnormalsizeunitybaselineskip=\dimen106
\IEEEnormaljot=\dimen107
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <5> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <5> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <7> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <7> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <8> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <8> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <9> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <9> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <10> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <10> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <11> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <11> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <12> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <12> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <17> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <17> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <20> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <20> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <24> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 724.
LaTeX Font Info:    Font shape `OT1/ptm/bx/it' in size <24> not available
(Font)              Font shape `OT1/ptm/b/it' tried instead on input line 724.
\IEEEilabelindentA=\dimen108
\IEEEilabelindentB=\dimen109
\IEEEilabelindent=\dimen110
\IEEEelabelindent=\dimen111
\IEEEdlabelindent=\dimen112
\IEEElabelindent=\dimen113
\IEEEiednormlabelsep=\dimen114
\IEEEiedmathlabelsep=\dimen115
\IEEEiedtopsep=\skip41
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@IEEEsubequation=\count85
\abovecaptionskip=\skip42
\belowcaptionskip=\skip43
\c@figure=\count86
\c@table=\count87
\@IEEEeqnnumcols=\count88
\@IEEEeqncolcnt=\count89
\@IEEEtmpitemindent=\dimen116
\c@IEEEbiography=\count90
\@IEEEtranrubishbin=\box26
) ("D:\Program Files (x86)\MikTeX 2.8\tex\latex\base\inputenc.sty"
Package: inputenc 2008/03/30 v1.1d Input encoding file
\inpenc@prehook=\toks15
\inpenc@posthook=\toks16
("D:\Program Files (x86)\MikTeX 2.8\tex\latex\base\latin9.def"
File: latin9.def 2008/03/30 v1.1d Input encoding file
)) ("D:\Program Files (x86)\MikTeX 2.8\tex\latex\ams\classes\amsthm.sty"
Package: amsthm 2004/08/06 v2.20
\thm@style=\toks17
\thm@bodyfont=\toks18
\thm@headfont=\toks19
\thm@notefont=\toks20
\thm@headpunct=\toks21
\thm@preskip=\skip44
\thm@postskip=\skip45
\thm@headsep=\skip46
\dth@everypar=\toks22
)
\c@thm=\count91

! LaTeX Error: Command \lem already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.18 \newtheorem{lem}
                     {\protect\lemmaname}
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

! Undefined control sequence.
l.18 \newtheorem{lem}{\protect\lemmaname
                                        }
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

("D:\Program Files (x86)\MikTeX 2.8\tex\generic\babel\babel.sty"
Package: babel 2008/07/06 v3.8l The Babel package
*************************************
* Local config file bblopts.cfg used
*
("D:\Program Files (x86)\MikTeX 2.8\tex\latex\00miktex\bblopts.cfg"
File: bblopts.cfg 2006/07/31 v1.0 MiKTeX 'babel' configuration
) ("D:\Program Files (x86)\MikTeX 2.8\tex\generic\babel\english.ldf"
Language: english 2005/03/30 v3.3o English support from the babel system
("D:\Program Files (x86)\MikTeX 2.8\tex\generic\babel\babel.def"
File: babel.def 2008/07/06 v3.8l Babel common definitions
\babel@savecnt=\count92
\U@D=\dimen117
)
\l@canadian = a dialect from \language\l@american 
\l@australian = a dialect from \language\l@british 
\l@newzealand = a dialect from \language\l@british 
))
No file newfile3.aux.
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 26.
LaTeX Font Info:    ... okay on input line 26.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 26.
LaTeX Font Info:    ... okay on input line 26.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 26.
LaTeX Font Info:    ... okay on input line 26.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 26.
LaTeX Font Info:    ... okay on input line 26.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 26.
LaTeX Font Info:    ... okay on input line 26.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 26.
LaTeX Font Info:    ... okay on input line 26.
[1{C:/Users/sbahmani/AppData/Local/MiKTeX/2.8/pdftex/config/pdftex.map}


]
(C:\Users\sbahmani\AppData\Local\Temp\lyx_tmpdir.Hp4480\lyx_tmpbuf7\newfile3.au
x) ) 
Here is how much of TeX's memory you used:
 1336 strings out of 495285
 21618 string characters out of 3179818
 71313 words of memory out of 3000000
 4591 multiletter control sequences out of 15000+200000
 28031 words of font info for 57 fonts, out of 3000000 for 9000
 14 hyphenation exceptions out of 8191
 26i,5n,19p,218b,119s stack positions out of 5000i,500n,10000p,200000b,50000s
{D:/Program Files (x86)/MikTeX 2.8/fonts/enc/dvips/fontname/8r.enc}<D:/Prog
ram Files (x86)/MikTeX 2.8/fonts/type1/urw/times/utmb8a.pfb><D:/Program Files (
x86)/MikTeX 2.8/fonts/type1/urw/times/utmr8a.pfb><D:/Program Files (x86)/MikTeX
 2.8/fonts/type1/urw/times/utmri8a.pfb>
Output written on newfile3.pdf (1 page, 19216 bytes).
PDF statistics:
 19 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)
Last edited by Stefan Kottwitz on Wed Jun 13, 2012 7:48 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Separate Counters for Theorems and Propositions

Post by Stefan Kottwitz »

Hi Sohail,

you could use a different name instead of lem.

Stefam
LaTeX.org admin
Post Reply