2

The following code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage[left=1.5in, right=1.5in, top=0.5in]{geometry}


\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem} 
\theoremstyle{remark}


\begin{document}
\title{Extra Credit}
\maketitle

\begin{definition}
If f is analytic at $z_0$, then the series

$$f(z_0) + f'(z_0)(z-z_0) + \frac{f''(z_0)}{2!}(z-z_0)^2 + \cdots = \sum_{n=0}^{\infty} \frac{f^{(n)}(z_0)}{n!}(z-z_0)^n \hspace{1cm}(1)$$ 

is called the Taylor series for f around $z_0$.
\end{definition}

\begin{theorem}
If f is analytic inside and on the simple closed positively oriented contour $\Gamma$ and if $z_0$ is any point inside $\Gamma$, then
$$f^{(n)}(z_0) = \frac{n!}{2\pi i} \int_{\Gamma} \frac{f(\zeta)}{(\zeta - z_0)^{n+1}}d\zeta \hspace{1cm} (n=1,2,3, \cdots )$$ \hfill (2)
\end{theorem}\hrulefill

produces enter image description here

How can I align the (1) and (2), and also get (2) to be on the same line as (n=1,2,3,...)?

  • Show your full work not just sniplet, we need a full but minimal example. Also you should not ude $$... $$ syntax in a latex document. It does not follow latex configurations. – daleif Mar 30 '19 at 17:58
  • @daleif: What do I use instead? Also, I edited and added the preamble. – K.M Mar 30 '19 at 18:04
  • 2
    Never even noticed you're setting the equation numbers by hand. You really should read a proper introduction to latex. You're already using amsmath, it provides many useful math constructions. Plus latex it self provides the equation environment which does exactly what you want here, automatically! – daleif Mar 30 '19 at 18:07
  • Off topic ... Unless this is just the residue of stripping down a longer file to get a MWE, there's nothing gained by specifying \theoremstyle after all your \newtheorem definitions. Also, it's more traditional for definitions to have their text in upright type; for that \theoremstyle{definition} would be the appropriate command. – barbara beeton Mar 30 '19 at 20:08
4

I highly suggest to use a different approach:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage[left=1.5in, right=1.5in, top=0.5in]{geometry}% I do not recommend to use this naiv canons of page construction for typographic reasons.  
\usepackage[noabbrev]{cleveref}%new package

\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem} 
\theoremstyle{remark}

\begin{document}
\title{Extra Credit}
\maketitle

\begin{definition}
If f is analytic at $z_0$, then the series
\begin{align}%observe that empty line is removed
    f(z_0) + f'(z_0)(z-z_0) + \frac{f''(z_0)}{2!}(z-z_0)^2 + \cdots = \sum_{n=0}^{\infty} \frac{f^{(n)}(z_0)}{n!}(z-z_0)^n \label{eq:Taylor} 
\end{align}%observe that empty line is removed
is called the \emph{Taylor series} for f around $z_0$.%The definition is not in italics here to emphasize the term. 
\end{definition}

\begin{theorem}
If f is analytic inside and on the simple closed positively oriented contour $\Gamma$ and if $z_0$ is any point inside $\Gamma$, then
\begin{align}
    f^{(n)}(z_0) = \frac{n!}{2\pi i} \int_{\Gamma} \frac{f(\zeta)}{(\zeta - z_0)^{n+1}}d\zeta \hspace{1cm} (n=1,2,3, \cdots ).%every parenthesis should be ended with a dot. 
\end{align}
\end{theorem}

\noindent\hrulefill %alternative:  \hrule

You can use refer to the equation by: \eqref{eq:Taylor} or \cref{eq:Taylor}. %This is the usual approach to refer to formulas. 

\end{document}

enter image description here

Please read the comments in the code and What are the differences between $$, \[, align, equation and displaymath?. Other useful staff is written in https://ctan.org/pkg/short-math-guide, https://ctan.org/pkg/lshort-english, and What are good learning resources for a LaTeX beginner?.

|improve this answer|||||
  • Can the downvoter please explain what is bad about this solution? – CampanIgnis Mar 30 '19 at 18:16
  • +1 for the answer, however you should mentioned in it that op approach to numbering of equations should be as you used in your answers. – Zarko Mar 30 '19 at 18:20
  • 4
    Why are you using align for one-line equations? It's not meant for that; it's meant for multi-line equations. Better to use equation. – barbara beeton Mar 30 '19 at 20:01
  • @barbarabeeton That is a fair point. Because I am sometimes lazy and in many (simple) examples align gives a similar result. – CampanIgnis Mar 30 '19 at 20:57
4

Use another approach, with the equation environment:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage[left=1.5in, right=1.5in, top=0.5in]{geometry}


\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem} 
\theoremstyle{remark}

\begin{document}
    \title{Extra Credit}
    \maketitle

    \begin{definition}
        If f is analytic at $z_0$, then the series

        \begin{equation}
            f(z_0) + f'(z_0)(z-z_0) + \frac{f''(z_0)}{2!}(z-z_0)^2 + \cdots = \sum_{n=0}^{\infty} \frac{f^{(n)}(z_0)}{n!}(z-z_0)^n
        \end{equation}

        is called the Taylor series for f around $z_0$.
    \end{definition}

    \begin{theorem}
        If f is analytic inside and on the simple closed positively oriented contour $\Gamma$ and if $z_0$ is any point inside $\Gamma$, then
        \begin{equation}
            f^{(n)}(z_0) = \frac{n!}{2\pi i} \int_{\Gamma} \frac{f(\zeta)}{(\zeta - z_0)^{n+1}}d\zeta \hspace{1cm} (n=1,2,3, \cdots )
        \end{equation}
    \end{theorem}
    \hrulefill
\end{document}

|improve this answer|||||
  • 3
    Never leave a blank line before \begin{equation}. One after \end{equation} can go, in case the equation ends the paragraph, which is not the case here. – egreg Mar 31 '19 at 19:22
4

One of the key features of (La)TeX is its ability to automatically number sections, theorems, list items and so on for you. This includes equations! Using

\begin{equation}
\label{somename}
    e=mc^2
\end{equation}

creates an equation with the next number in sequence, and you can refer back to it with \eqref{somename}. Just as with other automatically numbered thing, you can insert a new numbered equation before this one and all the numbers will be correctly updated. You can create unnumbered equations with the equation* environment (or, with less typing, \[ ... \]). Other equation-like environments also have a * version that doesn't number.

Note that it is not recommended to use $$...$$ for equations in LaTeX.

(Also, I'd strongly recommend numbering all Definitions, Theorems, etc. in the same series. It's really annoying to be looking for Theorem 4 in a long document when seeing Lemma 3 and Definition 5 give you no hint about whether you should look backwards or forwards.)

|improve this answer|||||

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.