3

I'm using LyX with "Theorems (AMS, numbered by type)" and "Theorems (AMS-extended, numbered by type)" modules. I would like to have the following output:

Axiom 1. Lorem.

Axiom 1'. Ipsum.

Is there a way to do this using LyX modules + ERT? In this link (Custom enumeration for axioms or hypothesis), someone made this in pure TeX. Since I'm a begginer, I don't know how to use this to solve my problem. Maybe the solution is to edit LyX's theorem module file, but I have no idea how to do this. In this other link (How to make "claim" environments look like "theorem" environment?) there's an example of editing LyX module files to get what you want.

0

1 Answer 1

5

Add the following in your Local Layout of LyX (Document > Settings... > Local Layout):

#\DeclareLyXModule{Other}
#DescriptionBegin
#Defines Axiomp (primed axioms)
#DescriptionEnd
#Requires: theorems-ams-extended
#Category: theorems

Format 35

Requires    amsmath

# The environments defined (regular and starred) are :
# - Axiomp

Style Axiomp
    CopyStyle             Theorem
    DependsOn               Theorem
    LatexName             axp
    LabelString           "Axiom \theaxp."
    Preamble
      \usepackage{etoolbox}
      \theoremstyle{plain}
      \newtheorem{axp}{\protect\axiomname}
      \makeatletter
      \patchcmd{\axp}{\th@plain}{\th@plain\setcounter{axp}{\numexpr\value{thm}-1}}{}{}
      \renewcommand{\theaxp}{\arabic{axp}$'$}
      \makeatother
    EndPreamble
    LangPreamble
      \providecommand{\axiomname}{_(Axiom)}
    EndLangPreamble
    BabelPreamble
      \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}}
    EndBabelPreamble
End

The click validate to add Axiomp to your list of styles. While your display may resemble

enter image description here

your output should result in

enter image description here


If you wish to have more control over the numbering, then you can add the following to your Document > Settings > LaTeX Preamble:

\makeatletter
\renewcommand{\axp}{%
  \@@thm
    {\let\thm@swap\@gobble\th@plain}
    {axp}
    {\protect\axiomname}}

\def\@@thm#1#2#3{% modified from original \@thm
  \ifhmode\unskip\unskip\par\fi
  \normalfont
  \trivlist
  \let\thmheadnl\relax
  \let\thm@swap\@gobble
  \thm@notefont{\fontseries\mddefault\upshape}%
  \thm@headpunct{.}% add period after heading
  \thm@headsep 5\p@ plus\p@ minus\p@\relax
  \thm@space@setup
  #1% style overrides
  \@topsep \thm@preskip               % used by thm head
  \@topsepadd \thm@postskip           % used by \@endparenv
  \def\@tempa{#2}\ifx\@empty\@tempa
    \def\@tempa{\@oparg{\@@begintheorem{#3}{}}[]}%
  \else
    \setcounter{#2}{\value{ax}}%
    \def\@tempa{\@oparg{\@@begintheorem{#3}{\csname the#2\endcsname}}[]}%
  \fi
  \@tempa
}

\def\@@begintheorem#1#2[#3]{%
  \typeout{hello}%
  \def\myvar{#3}\show\myvar%
  \deferred@thm@head{\the\thm@headfont \thm@indent
    \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
    \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\@iden}%
    \@ifempty{#3}{}{\setcounter{axp}{#3}}%\@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
    \let\thmnote\@gobble%
    \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
    \the\thm@headpunct
    \thmheadnl % possibly a newline.
    \hskip\thm@headsep
  }%
  \ignorespaces}
\makeatother

It modifies the theorem environment associated with primed axioms (axp) to reroute to a specialized \@@thm and \@@begintheorem constructions. Input of the form

enter image description here

yields as output

enter image description here

The use of an ERT for the optional argument is required, as is mentioned in the LyX wiki How to add optional arguments to environments:

Many LaTeX environments accept optional arguments that influence their behavior. The theorem environment, for example, accepts an optional argument that is typeset after the theorem number, often used for the name of the theorem or to give credit to its discoverer. In LaTeX, this would be written thus: \begin{theorem}[Cohen, 1961] or \begin{theorem}[Schröder-Bernstein Theorem], with results like these:

Theorem 1.1 (Cohen, 1961).
Theorem 1.2 (Schröder-Bernstein Theorem).

LyX offers no obvious way to do this, but in fact it is quite simple. All you need to do is enter the optional argument as ERT immediately following the appearance of "Theorem 1.2", or whatever, in LyX. It works because the optional argument follows the environment declaration.

4
  • 1
    +1 Nice. @LuizMMB note that anything you can do in a local layout you can also copy to a module. Local layouts are more portable (if you send to someone) because you do not have to remember to send the module. Modules however have the advantage that you can have a central module and then use it in many documents. See Help > Customization for more information.
    – scottkosty
    Nov 30, 2013 at 20:24
  • Werner, thanks. I tried to explain my problem in simple terms but, because of this, I left some important information out. I'm sorry. Actually, I want to have the following output: Axiom 6. Text. (paragraph) Normal text. (paragraph) Axiom 7. Text. (paragraph) Normal text. (paragraph) Axiom 6'. Text. / With your code, I got the following: Axiom 6. Text. (paragraph) Normal text. (paragraph) Axiom 7. Text. (paragraph) Normal text. (paragraph) Axiom 2'. Text. / (Don't worry about starting the axiom counting from 6. I'm just describing the output that I want of part of the document.)
    – LuizMMB
    Dec 2, 2013 at 16:38
  • 1
    @LuizMMB: I've updated my answer to allow for ad-hoc numbering of primed axioms.
    – Werner
    Mar 29, 2014 at 0:44
  • @Werner (Not OP here.) Thanks for this answer. This is a bit involved for a beginner. I'm interested in something really basic. Just getting numbered axiom environments just as I would use theorems and lemmas etc, nothing fancy. I copied your first thing into thing into the local layout and it worked but it outputs as "axiom 0" on each axiom. How can I get just standard numbering for axioms? Or even no numbering? Thanks!
    – Smithey
    Apr 11, 2022 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .