2

I'm using LyX 2.2dev on Mac together with Theorems (AMS), Theorems (AMS-Extended), Number Equations by Section and Theorems (Numbered by Sections) modules. I put \swapnumbers in my LaTeX preamble, but the numbers are still not swapped.

Plus, it seems like defining a new theorem or definition gets the indentation of a new paragraph, whereas I would like for the number of the theorem to start at the left most place.

EDIT Here is a picture of what I mean: enter image description here

Here is a "MWE" of what I mean: Original LyX file:


#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 479
\begin_document
\begin_header
\textclass amsbook
\begin_preamble
\usepackage[breaklinks,colorlinks=true,linkcolor=blue,
citecolor=blue, urlcolor=blue]{hyperref}
\usepackage{braket}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother
\usepackage{amsfonts}
\usepackage{dsfont}
\renewcommand{\vec}[1]{\mathbf{#1}}
\usepackage[scaled=0.88]{beraserif}
\usepackage[scaled=0.85]{berasans}
\usepackage[scaled=0.84]{beramono}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage[T1,small,euler-digits]{eulervm}
\end_preamble
\options reqno
\use_default_options true
\begin_modules
theorems-ams
eqs-within-sections
figs-within-sections
theorems-sec
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks true
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 0
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1cm
\topmargin 1cm
\rightmargin 1cm
\bottommargin 1cm
\secnumdepth 5
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\bullet 1 0 9 -1
\bullet 3 0 7 -1
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
Title
\end_layout

\begin_layout Chapter
First Chapter
\end_layout

\begin_layout Section
First Section
\end_layout

\begin_layout Standard
Here is some text.
 As it begins a paragraph, it starts indented.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
\end_layout

\begin_layout Claim
Some Claim [some words some words some words some words some words some
 words some words some words some words some words some words some words
 some words some words some words some words some words some words some
 words some words some words some words some words some words]
\end_layout

\begin_layout Definition
Some Definition
\end_layout

\end_body
\end_document

Example LaTeX induced by LyX:


%% LyX 2.2.0dev created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[oneside,english,reqno]{amsbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{luainputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm}
\setcounter{secnumdepth}{5}
\usepackage{amsthm}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{section}{chapter}
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}[section]
  \theoremstyle{remark}
  \newtheorem{claim}[thm]{\protect\claimname}
  \theoremstyle{definition}
  \newtheorem{defn}[thm]{\protect\definitionname}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[breaklinks,colorlinks=true,linkcolor=blue,
citecolor=blue, urlcolor=blue]{hyperref}
\usepackage{braket}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother
\usepackage{amsfonts}
\usepackage{dsfont}
\renewcommand{\vec}[1]{\mathbf{#1}}
\usepackage[scaled=0.88]{beraserif}
\usepackage[scaled=0.85]{berasans}
\usepackage[scaled=0.84]{beramono}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage[T1,small,euler-digits]{eulervm}

\AtBeginDocument{
  \def\labelitemii{\(\circ\)}
  \def\labelitemiv{\(\star\)}
}

\makeatother

\usepackage{babel}
  \providecommand{\claimname}{Claim}
  \providecommand{\definitionname}{Definition}
\providecommand{\theoremname}{Theorem}

\begin{document}

\title{Title}
\maketitle

\chapter{First Chapter}

\section{First Section}

Here is some text. As it begins a paragraph, it starts indented. Bla
bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla
bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla.
Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla
bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla
bla. Bla bla bla. Bla bla bla. Bla bla bla. Bla bla bla.
\begin{claim}
Some Claim {[}some words some words some words some words some words
some words some words some words some words some words some words
some words some words some words some words some words some words
some words some words some words some words some words some words
some words{]}
\end{claim}
\begin{defn}
Some Definition
\end{defn}

\end{document}

  • 1
    \swapnumbers must precede the \newtheorem specification for the theorem types it is to affect. it is not effective as a standalone command in the preamble. for clues about the other problems you report, a compilable example is needed. – barbara beeton Feb 19 '15 at 19:54
  • Hello, thanks for your help. I'm not sure how to implement your suggestion with LyX because in LyX you don't use \newtheorem. Anyways, I'll post an example of what I mean so you can better understand. – PPR Feb 19 '15 at 22:14
  • 1
    @PPR for future reference, for an MWE I think you wanted to have \swapnumbers in the LyX preamble (to show that it does not work). – scottkosty Feb 20 '15 at 3:30
4

Thanks for your nice MWEs and clear question!

The problem here is that you need to put something in the LaTeX preamble near the top. The preamble in LyX is only part of the whole LaTeX preamble. It just so happens that the parts of the preamble contributed to by the LyX modules that you load are placed above the user preamble. As @barbara beeton states in the comment, you need the \swapnumbers command to be before the \newtheorem commands. There are a few different ways you can work around this in LyX. One way is the following. We define a "Local Layout" (read Help > Customization for more information), which just happens to be output before the other modules.

To do this, go to Document > Settings > Local Layout and put the following:

Preamble
\swapnumbers
EndPreamble

Then press "Validate". Then press "OK". That's it.

This leads to the following .lyx file (my LyX dev is slightly newer than yours so either update and recompile or just replacing 480 with 479 should work):

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 480
\begin_document
\begin_header
\textclass amsbook
\begin_preamble
\usepackage[breaklinks,colorlinks=true,linkcolor=blue,
citecolor=blue, urlcolor=blue]{hyperref}
\usepackage{braket}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother
\usepackage{amsfonts}
\usepackage{dsfont}
\renewcommand{\vec}[1]{\mathbf{#1}}
\usepackage[scaled=0.88]{beraserif}
\usepackage[scaled=0.85]{berasans}
\usepackage[scaled=0.84]{beramono}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage[T1,small,euler-digits]{eulervm}
\end_preamble
\options reqno
\use_default_options true
\begin_modules
theorems-ams
eqs-within-sections
figs-within-sections
theorems-sec
\end_modules
\maintain_unincluded_children false
\begin_local_layout
Preamble
\swapnumbers
EndPreamble
\end_local_layout
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks true
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 0
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1cm
\topmargin 1cm
\rightmargin 1cm
\bottommargin 1cm
\secnumdepth 5
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\bullet 1 0 9 -1
\bullet 3 0 7 -1
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
Title
\end_layout

\begin_layout Chapter
First Chapter
\end_layout

\begin_layout Section
First Section
\end_layout

\begin_layout Standard
Here is some text.
 As it begins a paragraph, it starts indented.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
\end_layout

\begin_layout Claim
Some Claim [some words some words some words some words some words some
 words some words some words some words some words some words some words
 some words some words some words some words some words some words some
 words some words some words some words some words some words]
\end_layout

\begin_layout Definition
Some Definition
\end_layout

\end_body
\end_document

and the following exported .tex file:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 480
\begin_document
\begin_header
\textclass amsbook
\begin_preamble
\usepackage[breaklinks,colorlinks=true,linkcolor=blue,
citecolor=blue, urlcolor=blue]{hyperref}
\usepackage{braket}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother
\usepackage{amsfonts}
\usepackage{dsfont}
\renewcommand{\vec}[1]{\mathbf{#1}}
\usepackage[scaled=0.88]{beraserif}
\usepackage[scaled=0.85]{berasans}
\usepackage[scaled=0.84]{beramono}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage[T1,small,euler-digits]{eulervm}
\end_preamble
\options reqno
\use_default_options true
\begin_modules
theorems-ams
eqs-within-sections
figs-within-sections
theorems-sec
\end_modules
\maintain_unincluded_children false
\begin_local_layout
Preamble
\swapnumbers
EndPreamble
\end_local_layout
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks true
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 0
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1cm
\topmargin 1cm
\rightmargin 1cm
\bottommargin 1cm
\secnumdepth 5
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\bullet 1 0 9 -1
\bullet 3 0 7 -1
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Title
Title
\end_layout

\begin_layout Chapter
First Chapter
\end_layout

\begin_layout Section
First Section
\end_layout

\begin_layout Standard
Here is some text.
 As it begins a paragraph, it starts indented.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
 Bla bla bla.
\end_layout

\begin_layout Claim
Some Claim [some words some words some words some words some words some
 words some words some words some words some words some words some words
 some words some words some words some words some words some words some
 words some words some words some words some words some words]
\end_layout

\begin_layout Definition
Some Definition
\end_layout

\end_body
\end_document

This leads to the following PDF output:

enter image description here

By the way, if you are interested it would be great if you subscribed to lyx-devel (and lyx-users). Most of us on the list use Linux, so it would be nice to have feedback from someone using the development version of LyX on Mac. See here for more information: http://www.lyx.org/MailingLists

  • Perfect, thank you! May I ask if you have an idea about the extra indentation I was asking about? P. S. I am on the LyX dev mailing list, and have received some very good answers there in the past about Mac dev versions! – PPR Feb 20 '15 at 10:38
  • Another question: I am using amsbook. When I don't do \swapnumbers, I get the numbering chapter.section.number. However, after the swapping I have only section.number. How can I fix this? – PPR Feb 20 '15 at 12:37
  • @PPR I don't know. I actually know little LaTeX. I am only generally useful at converting exiting LaTeX answers to LyX answers. You might want to start a new question (and just copy the same MWE?). – scottkosty Feb 20 '15 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.