Environment formatting: how to display the name of an axiom instead of its counter number
You can do it with amsthm
(better than ntheorem
, in my opinion).
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{xparse}
\usepackage{hyperref}
\usepackage{cleveref}
\newtheorem{inneraxiom}{Axiom}
\newtheorem*{inneraxiomnonumber}{\axiomname}
\providecommand{\axiomname}{}
\makeatletter
\NewDocumentEnvironment{axiom}{o}
{%
\IfNoValueTF{#1}
{\inneraxiom}% no optional argument, nothing special
{% optional argument
\renewcommand{\axiomname}{#1}% set \axiomname to #1
\def\@currentlabel{#1}% for \ref
\inneraxiomnonumber% start the unnumbered environment
}%
}
{\IfNoValueTF{#1}{\endinneraxiom}{\endinneraxiomnonumber}}
\makeatother
\begin{document}
\begin{axiom}\label{axiom:standard}
This is a standard axiom.
\end{axiom}
\begin{axiom}[Francesco's axiom]\label{axiom:francesco}
All axioms are useful.
\end{axiom}
\cref{axiom:standard}
\ref{axiom:francesco}
\end{document}
It makes little sense to use \cref
for named axioms.
It is very easy with ntheorem
which defines the empty
and emptybreak
styles. These styles define no counter nor header: only the optional argument is printed.
\documentclass[11pt]{article}
\usepackage{ntheorem}
\theoremstyle{empty}
\theoremheaderfont{\bfseries\upshape}
\theorembodyfont{\itshape}
\setlength{\labelsep}{0pt}
\newtheorem{named}{}
\theoremstyle{emptybreak}
\newtheorem{namedbreak}{}
\begin{document}
\begin{named}[Axiom of choice. ] If $X$ is a set of nonempty sets, there exists a function $f$ on $X$ such that, for any $A\in X$, one has $f(A)\in A$.
\end{named}
\begin{namedbreak}[Dr Faustroll’s axiom]
God is the tangential point of $0$ and $\infty$.
\end{namedbreak}
\end{document}
Edit: To have the same layout with ntheorem
as with the basic styles of amsthm
, use this in the preamble:
\usepackage{ntheorem}
\theoremheaderfont{\bfseries\upshape}
\theorembodyfont{\itshape}
\theoremseparator{. }
%%%%%%%%%
\theoremstyle{empty}
\setlength{\labelsep}{0pt}
\newtheorem{named}{}
\theoremstyle{emptybreak}
\newtheorem{namedbreak}{}
%%%%%%%%%%
\theoremstyle{plain}
\newtheorem{myth}{Theorem}[section]
\newtheorem{myprop}[myth]{Proposition}
\newtheorem{mylemma}[myth]{Lemma}
\theoremstyle{definition}
\theorembodyfont{\upshape}
\newtheorem{mydef}{Definition}[section]
%%%%%%%%%%%%%%%%%
\makeatletter
\newtheoremstyle{remark}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textup{##2}\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textup{##2}\ (##3)\theorem@separator]}
\makeatother
\theoremstyle{remark}
\theoremheaderfont{\itshape}
\newtheorem{myrmk}{Remark}[section]
\newtheorem{myex}{Example}[section]
Edit: I cleaned your last code and made it fully functional. In particular, when you declare a theorem structure, say mytheorem
, with the empty
style, you have to write \newtheorem{mytheorem}{}
(with a last empty argument).
\documentclass[11pt]{article}
\usepackage{amsmath, amssymb}
\usepackage[amsmath,thref, thmmarks]{ntheorem}%
\theoremheaderfont{\normalfont\bfseries}
\theoremseparator{. }
%%%%%%%%%
\theoremstyle{emptybreak}
\theorembodyfont{\normalfont}
\setlength{\labelsep}{0pt}
\newtheorem{myax}{}
%%%%%%%%%
\theoremstyle{plain}
\theorembodyfont{\itshape}
\newtheorem{myth}{Theorem}[section]
\newtheorem{myprop}[myth]{Proposition}
\newtheorem{mylemma}[myth]{Lemma}
%%%%%%%%%%%
\theorembodyfont{\normalfont}
\newtheorem{mydef}{Definition}[section]
%%%%%%%%%%%%%%%%%%
\makeatletter
\newtheoremstyle{remark}
{\item[\hskip\labelsep\theorem@headerfont ##1\ \textup{##2}\theorem@separator]}
{\item[\hskip\labelsep \theorem@headerfont ##1\ \textup{##2}\ (##3)\theorem@separator]}
\makeatother
\theoremstyle{remark}
\theoremheaderfont{\itshape}
\newtheorem{myrmk}{Remark}[section]
\newtheorem{myex}{Example}[section]
%%%%%%%%%%%%%%%%%
\theoremstyle{nonumberplain}
\theoremsymbol{\ensuremath\square}
\newtheorem{proof}{Proof}
%%%%%%%%%%%%%%%%%%%%%
\usepackage{cleveref}
\crefname{myth}{Theorem}{Theorems}
\crefalias{Myth}{myth}
\crefname{myprop}{Proposition}{Propositions}
\crefalias{Myprop}{myprop}
\crefname{mylemma}{Lemma}{Lemmas}
\crefalias{Mylemma}{mylemma}
\crefname{mydef}{Definition}{Definitions}
\crefalias{Mydef}{mydef}
\crefname{myrmk}{Remark}{Remarks}
\crefalias{Myrmk}{myrmk}
\crefname{myex}{Example}{Examples}
\crefalias{Myex}{myex}
\crefname{myax}{Axiom}{Axioms}
\crefalias{Myax}{myax}
\begin{document}
\begin{mydef}
\textbf{Egotist}, n. A person of low taste, more interested in him\-self than in me.
\end{mydef}
\begin{myth}
My theorem.
\end{myth}
\begin{proof}
\[ \text{Fiddle dee dee!} \]
\end{proof}
\end{document}
amsthm
provides a starred version of \newtheorem
that substitutes the specified argument for the usual numbered heading. So this definition would produce the heading you want:
\theoremstyle{definition}
\newtheorem*{axch}{Axiom of Choice}
Of course, the heading is now fixed, so if a different "specific" heading is wanted, a separate \newtheorem*
is needed.
This is described on page 3 of the amsthm
user guide (texdoc amsthdoc
).