Re: Using the theorem enviroment with Koma-script in 1.4.x

2006-05-17 Thread Ingo Klöcker
Am Mittwoch, 17. Mai 2006 09:57 schrieb John McCabe-Dansted:
> When writting my thesis I found that I needed komascript to format a
> Thesis correctly, but that LyX would only allow me to enter Theorems
> in a AMS class. My solution to this was to have a Book(koma-script)
> main document that included Book(AMS) LyX documents which contained
> the theorems, lemmas etc.
>
> However with 1.4.1 LyX now generates a prompt
>   "LyX: Different textclasses
>   Included file `afile.lyx'
>   has textclass `amsbook'
>   while parent file has textclass `scrbook'."
> for each included file. As I have a dozen included files, just
> clicking OK can take a while. Does anyone know of a way to suppress
> these dialogs or otherwise allow theorems to be entered via the LyX
> GUI into a komascript document?

As always in such a case it's best to write a new layout file. 
Obviously, this layout file should be derived from the KOMA book layout 
file. For my thesis I've created a layout file for KOMA book with 
ntheorem and paralist package. I've attached the corresponding files. 
You have to put them into ~/.lyx/layouts (at least on Linux/Unix). Then 
you have to run Edit->Reconfigure... After restarting the new text 
class (called "book (Doktorarbeit koma)") should be available. If it 
works then switch the class of all files to this class. Make sure you 
make a backup of your thesis before you try this!

Regards,
Ingo

# Author: Ingo Kloecker <[EMAIL PROTECTED]>
# This defines the theorem styles environments provided by ntheorem.sty.
# Most of this stuff was adapted from the layout files for AMS document
# classes.
# This version has Theorems and other results numbered in one sequence, and all
# numbered environments (figures as well) containing the section number.
# (Theorem (1.1), Corollary (1.2) Theorem (1.3), etc.
# This is the english version.

# Due to a bug (?) in LyX the following has to be copied to the Preamble block
# of the layout file which includes this file. Changing it here doesn't have
# any effect.
Preamble
  \usepackage{amsmath}
  \usepackage[standard,amsmath,thmmarks]{ntheorem}
  \theoremstyle{plain}
  \newtheorem{thm}{Theorem}[chapter]
EndPreamble

# The environments defined are :
# - Proof
# - Theorem
# - Theorem*
# - Lemma
# - Lemma*
# - Proposition
# - Proposition*
# - Corollary
# - Corollary*
# - Definition
# - Definition*
# - Remark
# - Remark*
# - Example
# - Example*

# Proof style declaration
Style Proof
  MarginFirst_Dynamic
  LatexType Environment
  LatexName proof
  NextNoIndent  1
  LabelSep  xx
  ParIndent MMM  
  ParSkip   0.4
  ItemSep   0.2
  TopSep0.7
  BottomSep 0.7
  ParSep0.3
  Align Block
  AlignPossible Block, Left
  LabelType Static
  LabelString   "Proof."
  EndLabelType  Box
  
  # standard font definition
  Font
Shape   Up
SizeNormal
  EndFont

  # label font definition
  LabelFont
Shape   Italic
  EndFont

  # We don't want the preamble from Theorem
  Preamble
  EndPreamble 
End  

# Theorem-numbered style declaration
Style Theorem
  MarginFirst_Dynamic
  LatexType Environment
  LatexName thm
  NextNoIndent  1
  LabelSep  xx
  ParIndent MMM  
  ParSkip   0.4
  ItemSep   0.2
  TopSep0.7
  BottomSep 0.7
  ParSep0.3
  Align Block
  AlignPossible Block, Left
  LabelType Static
  LabelString   "Theorem #."

  
  # standard font definition
  Font
Shape   Italic
SizeNormal
  EndFont

  # label font definition
  LabelFont
Shape   Up
Series  Bold
  EndFont

End  

# Theorem-unnumbered style declaration
Style Theorem*
  CopyStyle Theorem
  LatexName thmNN*
  LabelString   "Theorem."

  Preamble
\theoremstyle{plain}
\newtheorem*{thmNN*}{Theorem} %% unnumbered; needed for LyX
  EndPreamble
End  

# Lemma-numbered style declaration
Style Lemma
  CopyStyle Theorem
  LatexName lem
  LabelString   "Lemma #."

  Preamble
\theoremstyle{plain}
\newtheorem{lem}[thm]{Lemma} %%Delete [thm] to re-start numbering
  EndPreamble
End  

# Lemma-unnumbered style declaration
Style Lemma*
  CopyStyle Theorem
  LatexName lemNN*
  LabelString   "Lemma."

  Preamble
\theoremstyle{plain}
\newtheorem*{lemNN*}{Lemma} %% unnumbered; needed for LyX
  EndPreamble
End  

# Proposition-numbered style declaration
Style Proposition
  CopyStyle Theorem
  LatexName prop
  LabelString   "Proposition #."

  Preamble
\theoremstyle{plain}
\newtheorem{prop}[thm]{Proposi

Re: Using the theorem enviroment with Koma-script in 1.4.x

2006-05-17 Thread Richard Heck

And after clicking all the dialog boxes, you actually get the document
processed correctly? I wouldn't think you would, since the theorem
environment simply isn't defined in the koma-script book class, and I've
run a short test here with just one included document. (I've attached
the test files.) Even if I include the AMS math packages, I get the
LaTeX error: Environment theorem undefined. The problem isn't that the
LyX GUI isn't allowing you to enter the theorem environment in
koma-script: It's that the theorem environment doesn't exist in koma-script.

LyX is trying to warn you about exactly this problem: When you include
the Book(AMS) documents in the main Book(koma-script) documents, the
class of the included document is irrelevant. The class has already been
set by the main document, and it cannot be changed mid-stream: It's a
document-global property. LyX will allow you to create and edit the
included documents with whatever class you wish, since it doesn't know
they're included documents. It will only complain when you try to
process the master document. (Maybe LyX should complain when you try to
include a document with a different class?) So the solution you mention
isn't a solution to your problem: It won't work.

If you want to use Book(koma-script) for the main document, then the
only way you can use the theorem environment is to define it yourself in
the preamble. (Maybe you've already done so. If so, see below.) If
you're using other environments from the AMS book class, such as proof,
then those will have to be defined, too. Maybe someone somewhere along
the way wrote a style file to do this: Check CTAN. But another, simpler
option may be to use the AMS book class and then make whatever changes
you need to make to it (using packages like titlesec, titletoc, and
tocloft, if there are issues about how section headings and the like are
set).

Now maybe you've already figured out this issue and just want to know
how to be allowed to enter the theorem environment you've already
defined. In that case, the answer is to modify the koma-script book
layout. That's in scrbook.layout, and you should be able simply to
cut-and-paste from amsbook.layout to get whatever other environments you
want into the new layout. You will also want to change the second line
(the one you're warned not to change!) in your local copy, so you can
use both it and the original koma-script book layout.

Richard

John McCabe-Dansted wrote:
> When writting my thesis I found that I needed komascript to format a
> Thesis correctly, but that LyX would only allow me to enter Theorems
> in a AMS class. My solution to this was to have a Book(koma-script)
> main document that included Book(AMS) LyX documents which contained
> the theorems, lemmas etc.
>
> However with 1.4.1 LyX now generates a prompt
>  "LyX: Different textclasses
>  Included file `afile.lyx'
>  has textclass `amsbook'
>  while parent file has textclass `scrbook'."
> for each included file. As I have a dozen included files, just
> clicking OK can take a while. Does anyone know of a way to suppress
> these dialogs or otherwise allow theorems to be entered via the LyX
> GUI into a komascript document?
>



test.lyx
Description: application/lyx


thm.lyx
Description: application/lyx


Using the theorem enviroment with Koma-script in 1.4.x

2006-05-17 Thread John McCabe-Dansted

When writting my thesis I found that I needed komascript to format a
Thesis correctly, but that LyX would only allow me to enter Theorems
in a AMS class. My solution to this was to have a Book(koma-script)
main document that included Book(AMS) LyX documents which contained
the theorems, lemmas etc.

However with 1.4.1 LyX now generates a prompt
 "LyX: Different textclasses
 Included file `afile.lyx'
 has textclass `amsbook'
 while parent file has textclass `scrbook'."
for each included file. As I have a dozen included files, just
clicking OK can take a while. Does anyone know of a way to suppress
these dialogs or otherwise allow theorems to be entered via the LyX
GUI into a komascript document?

--
John C. McCabe-Dansted
PhD Student
University of Western Australia