# Axiom 1 and 1' in LyX

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.

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\captionslang{\renewcommand{\axiomname}{_(Axiom)}}
EndBabelPreamble
End


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

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\thm@swap\@gobble
\thm@notefont{\fontseries\mddefault\upshape}%
\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%
\@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%
}%
\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

yields as output

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.

• +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 '13 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 '13 at 16:38
• @LuizMMB: I've updated my answer to allow for ad-hoc numbering of primed axioms. – Werner Mar 29 '14 at 0:44