3

At the beginning I use \numberwithin{equation}{subsection} so every time I use \begin{equation} environment, it will tag my equations on the right with respect to sections or subsections.

\documentclass[12pt]{article}
\usepackage{titlesec}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{enumerate}
\setlength{\textwidth}{16cm}
\setlength{\textheight}{23cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\topmargin}{0cm}
\title{{\textbf{\textrm TITLE}}}
\author{Bruce}
\date{\today}


\usepackage{xcolor}
\numberwithin{equation}{subsection}
\newsavebox\thmbox
\newtheorem{mytheorem}{Theorem}
\newenvironment{theorem}%
  {\begin{lrbox}{\thmbox}%
   \begin{minipage}{\dimexpr\linewidth-2\fboxsep}
   \begin{mytheorem}}%
  {\end{mytheorem}%
   \end{minipage}%
   \end{lrbox}%
   \begin{trivlist}
     \item[]\colorbox{lightgray}{\usebox\thmbox}
   \end{trivlist}}
\newtheorem{mydef}{Definition}
\begin{document}
\maketitle
\section{First Chapter}
\subsection{First subsection}
\begin{equation}
F=ma
\end{equation}
\begin{theorem}
Force is equal mass times acceleration. 
\end{theorem}
\end{document}

It will tag F=ma as (1.1.1). Now I also want to number my sentence using the same numbering system, without centring the whole sentence. For example, If I use

\begin{equation}
\mbox{Force is equal mass times acceleration.}
\end{equation}

It will still number the sentence, but its output acts like an equation(centring). How can I fix that?

I try add more text in the \theorem environment. But the space between them are too large, or am I using the incorrect code for flalign?

\begin{theorem}
\begin{flalign}
\text{(1)Force is equal mass times acceleration.}&&
\end{flalign}
\begin{flalign}
\text{(2)Mass in conserved in general.}&&
\end{flalign}
\end{theorem}
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Dec 15 '14 at 15:44
  • what do you mean by sentence(theorem) ? I honestly can not guess. sentences are not normally numbered in latex, and your test document has no theorems or sentences in it. – David Carlisle Dec 15 '14 at 15:52
  • Your example just produces the error ! Incomplete \iffalse; all text was ignored after line 6. <inserted text> \fi – David Carlisle Dec 15 '14 at 15:54
  • Sorry it should work now. I want to number my theorem 'Force is equal mass times acceleration' as (1.1.2). – user3624246 Dec 15 '14 at 16:07
  • Add \numberwithin{theorem}{subsection}. – Gonzalo Medina Dec 15 '14 at 16:12
3

You can use flalign instead of equation with a double & at the end of the sentence:

\begin{flalign}
\text{Force is equal mass times acceleration.}&&
\end{flalign}

MWE (note the use of \text instead of \mbox)

\documentclass[12pt]{article}
\usepackage{titlesec}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{enumerate}
\setlength{\textwidth}{16cm}
\setlength{\textheight}{23cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\topmargin}{0cm}
\title{{\textbf{\textrm TITLE}}}
\author{Bruce}
\date{\today}


\usepackage{xcolor}
\numberwithin{equation}{subsection}
\newsavebox\thmbox
\newtheorem{mytheorem}{Theorem}
\newenvironment{theorem}%
  {\begin{lrbox}{\thmbox}%
   \begin{minipage}{\dimexpr\linewidth-2\fboxsep}
   \begin{mytheorem}}%
  {\end{mytheorem}%
   \end{minipage}%
   \end{lrbox}%
   \begin{trivlist}
     \item[]\colorbox{lightgray}{\usebox\thmbox}
   \end{trivlist}}
\newtheorem{mydef}{Definition}
\begin{document}
\maketitle
\section{First Chapter}
\subsection{First subsection}
\begin{equation}
F=ma
\end{equation}
\begin{flalign}
\text{Force is equal mass times acceleration.}&&
\end{flalign}
\begin{theorem}
Force is equal mass times acceleration.
\end{theorem}
\end{document} 

Output

enter image description here


EDIT

I don't know what you are trying to achieve, maybe this?

enter image description here

To have that, add the following lines in your preamble

\makeatletter
\newcommand{\numleft}{\tagsleft@true}
\newcommand{\numright}{\tagsleft@false}
\makeatother

The first line simulates the option leqno of amsmath and the second the option reqno.

Use them like

\begin{theorem}
\numleft
\begin{flalign}
\qquad\qquad&\text{Force is equal mass times acceleration.}&\\
\qquad\qquad&\text{Force is equal mass times acceleration again.}&
\end{flalign}
\numright
\end{theorem}

Complete code

\documentclass[12pt]{article}
\usepackage{titlesec}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{enumerate}
\setlength{\textwidth}{16cm}
\setlength{\textheight}{23cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\topmargin}{0cm}
\title{{\textbf{\textrm TITLE}}}
\author{Bruce}
\date{\today}


\makeatletter
\newcommand{\numleft}{\tagsleft@true}
\newcommand{\numright}{\tagsleft@false}
\makeatother

\usepackage{xcolor}
\numberwithin{equation}{subsection}
\newsavebox\thmbox
\newtheorem{mytheorem}{Theorem}
\newenvironment{theorem}%
  {\begin{lrbox}{\thmbox}%
   \begin{minipage}{\dimexpr\linewidth-2\fboxsep}
   \begin{mytheorem}}%
  {\end{mytheorem}%
   \end{minipage}%
   \end{lrbox}%
   \begin{trivlist}
     \item[]\colorbox{lightgray}{\usebox\thmbox}
   \end{trivlist}}
\newtheorem{mydef}{Definition}
\begin{document}
\maketitle
\section{First Chapter}
\subsection{First subsection}
\begin{equation}
F=ma
\end{equation}

\begin{theorem}
\numleft
\begin{flalign}
\qquad\qquad&\text{Force is equal mass times acceleration.}&\\
\qquad\qquad&\text{Force is equal mass times acceleration again.}&
\end{flalign}
\numright
\end{theorem}
\end{document} 
  • How to number them (in the front this time) under my 'theorem' environment? I tried \begin{theorem} \begin{enumerate} \item \begin{flalign} \text{Force is equal mass times acceleration.}&& \end{flalign} \end{enumerate} \end{theorem} But it doesn't look nice. – user3624246 Dec 15 '14 at 16:59
  • @user3624246 See the edit – karlkoeller Dec 15 '14 at 17:39
  • @user3624246 See the edit again.... – karlkoeller Dec 15 '14 at 18:04
  • @user3624246 Happy about that. Remember that you can accept the answer to mark the question as solved. See How do you accept an answer? – karlkoeller Dec 15 '14 at 18:22

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.