3

I have seen some nice functionality in the the latex files of certain math journals and I want to create that functionality in my own .tex file. Right now, I can write

\begin{equation}\label{eq:STUFF}
    MATH STUFF
\end{equation}

and this will produce a numbered equation. Elsewhere, I can refer to "Equation \ref{eq:STUFF}," and it will take care of the numbering for me. Here is the new functionality I am looking for: I want to be able to write

\begin{theorem}\label{thm:LATEX}
   For example, this theorem is Theorem 2.5.1 because it is the first theorem in the fifth subsection of the second section.
\end{theorem}

I want to be able to write "Theorem \ref{thm:LATEX}" and have my PDF build with the numbers for the theorem's number in this format: [Section].[Subsection].[Item], in this case "2.5.1."

I also want to be able to toggle the numbering for unnumbered items such as a simple remark, or

\begin{proof}
     Proof of the above numbered theorem.
\end{proof}

where I would refer to this as "proof of Theorem \ref{thm:LATEX}" and I would not want the item counter to count the proof, so that the item following the proof would be item "2.5.2"

BELOW FIND MY TEX FILE WITH THE NOTES ON WHAT I WANT:


\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}  % needed for figures
\usepackage{bm}        % for math
\usepackage{amssymb}   % for math
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{titling}
\usepackage{bigints}
\usepackage{mathtools}
\usepackage{centernot}
\usepackage[left=1in,right=1in,top=0.468in,bottom=.768in,centering,includeheadfoot]{geometry}

\title{{\LARGE{ \textbf{Proof of Latex}}}}

\author{\Large{Hodor P. Bojangleton}}

\begin{document}

\renewcommand{\abstractname}{\vspace{-\baselineskip}}
\date{\today}
\maketitle

\tableofcontents
\newpage
\large{

\section{SECTION 1}

Currently this starts with 0 because it is counting the chapters, but I only want to use sections and subsections.  I need to get rid of the counting for chapters.

Items in this space should be numbered 1.0.X

Here I create and equation with the "begin/end" syntax that I want for my new commands.

\begin{equation}\label{eq:111}
1+1=2
\end{equation}

I want to add a zero for the subsection in the numbering of Equation \ref{eq:111}. 




\subsection{SUBSECTION 1.1}

Here we have the 0 chapter number than I want to get rid of.

Items in this space should be numbered 1.1.X

I want the item name and number to appear aesthetically like:\newline

\noindent {\Large \textbf{Theorem 1.1.1}} After I write "begin theorem" to mimic the "begin equation" functionality that I already have, I want the text I write between "begin" and "end" to show up on the same line as the large bold theorem header.\newline

\noindent {\Large \textit{Proof.}}  This is an unnumbered proof of the above theorem.\newline

\noindent {\Large \textbf{Lemma 1.1.2}} The item counter did not increment for the proof.


\section{SECTION 2}

Items in this space should be numbered 2.0.X

\subsection{SUBSECTION 2.1}

Items in this space should be numbered 2.1.X

\subsection{SUBSECTION 2.2}

Items in this space should be numbered 2.2.X

}
\end{document}
6
  • 1
    Use either amsthm or ntheorem, whichever you prefer. The documentation has many examples.
    – Davislor
    Apr 3, 2019 at 21:13
  • In the future, please indent code fragments with four spaces (or selecting them and then hitting the {} button in the post editor). It’d also help to make your examples minimal.
    – Davislor
    Apr 3, 2019 at 21:19
  • In particular, see section 2 of the ntheorem manual for information on the [section] option to \newtheorem and the \theoremnumbering, \theoremheaderfont and \theorembodyfont commands.
    – Davislor
    Apr 3, 2019 at 21:21
  • I've reformatted the code for you. @Davislor: why not make these good comments into an answer. Apr 3, 2019 at 21:35
  • Much better! I hope this answers your question.
    – Davislor
    Apr 3, 2019 at 23:35

1 Answer 1

2

You can accomplish this with the ntheorem package. The [section] option of newtheorem controls whether theorem labels contain a section number. See the ntheorem manual for details and more examples.

\documentclass{report}
\usepackage{mathtools}
\usepackage[amsmath, thmmarks, thref]{ntheorem}
\usepackage{unicode-math}
\usepackage{microtype}
\usepackage[paperwidth=10cm]{geometry}

\defaultfontfeatures{Scale = MatchLowercase}
\setmathfont{Latin Modern Math}
\setmathfont[range=\QED]{XITS Math}
\renewcommand\qedsymbol{\ensuremath{\QED}}

\theoremstyle{marginbreak}
\theoremheaderfont{\normalfont\bfseries}
\theorembodyfont{\slshape}
\theoremsymbol{\qedsymbol}
\theoremseparator{:}
\newtheorem{Theorem}{Theorem}[section]

\begin{document}

\section{Introduction}\label{sec:introduction}

We will introduce theorem \thref{thm:112} shortly.  Wait for it!

\subsection*{The Theorem}\label{subsec:01}

\begin{Theorem}[An Exercise in Peano Arithmetic]\label{thm:112}[Theorem]
When I was young and brash, I would always ask on the first day of every math
class I took, “Is this where we finally learn why \(1+1=2\)?”

One day, a classmate said to me, “You \textbf{do} know that one plus one is \textbf{defined} as two?”

When I told this story later, it kicked off an argument over whether he should’ve said, “Two is defined as one plus one.”

Thus, by definition, \( 1 + 1 = 2 \).
\end{Theorem}

\end{document}

Example theorem

This isn’t quite minimal, and I’ve taken a few liberties with your template. In particular, I loaded unicode-math and set the Q.E.D. symbol to the “tombstone” used in some editions of The Art of Computer Programming.

Adding the amsthm package option would allow you to use a proof environment within theorems.

Since this is a report, you could also start a \chapter.

You must log in to answer this question.

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