1

For my homework I am required to replicate (among other things) the following equation:

I was able to achieve this using align:

\begin{align*}
    some stuff with & \tag{15} \\
            & some  other stuff & \qquad \qquad \qquad \quad \; 0 < x < 1. 
\end{align*}

but I had to use 4 \qquad's because the part on the right would not be on the right! This is ugly, but what bothers me more is the fact that align had worked before for this equation:

I used the following code here:

\begin{align*}
    foo &= bar \tag{15} \\
        &baz \\
    foo &= bar \\
        & baz & 0 < x < 1,
\end{align*} 

You can see that the part on the right sits exactly where it should without using an embarrassing amount of \quads.

How do make those this equation align properly? How do I make a part of a line flush to the right?

Just for reference, this is how my PDF looks with the code above (this is from Bateman Manuscript Project, Higher Transcendental Functions vol. I, p. 23):


Here is my full code:

\documentclass[12pt,leqno]{article} %leqno is to align equation labels to left

\usepackage[bottom=0in, top=0.4in, left=1.2in, right=1.2in]{geometry} % set margins to look like the original
\usepackage{xfrac, relsize,fancyhdr} % for slanted fractions, bigger integral signs, and some other things
\usepackage[fleqn]{amsmath} % for equations flushed to left, among other things
\usepackage[nice]{nicefrac} % for nice slanted fractions

\DeclareMathOperator{\csch}{csch}

\pagestyle{fancy}
\fancyhf{} % removes default page number
\renewcommand{\headrulewidth}{0pt} % removes the top line

\headheight=15pt % smaller header height was yielding warnings in pdflatex compiler
\fancyhead[C]{GAMMA FUNCTION} % adds header
\voffset=0.15in % header position


\begin{document}

\rhead{23} % ads page number as a header
\lhead{\textbf{1.9.1}} 

\noindent \textbf{1.9.1. \; Kummer's series for } \textbf{$\log \Gamma (z)$} \\

The function $\log \Gamma (x)$, $0 < x < 1$, can be expanded in a Fourier series. We shall use the known Fourier expansions (Bromwich, 1947, pp. 356, 393, and 370 respectively):
\begin{align*}
    & \log(\sin\pi x) =  -  \log 2  -  \sum_{n=1}^{\infty} \, (1/n) \cos (2\pi n x), \\
    & \csch (\nicefrac{1}{2} \, t) \, \sinh (\nicefrac{1}{2}-x)t = 8 \pi \, \sum_{n=1}^{\infty} [n \; \sin(2\pi n x)]/(t^2 + 4{\pi}^2 n^2), \\
    & \pi (1 - 2x) = 2 \sum_{n=1}^{\infty} (1/n) \sin(2 \pi nx).
\end{align*}

If these are substituted in (7) with $z=x$, we have to evaluate the integral 

\[\mathlarger{\int_0^{\infty}} \left(\frac{2\pi n}{t^2 + 4{\pi}^2 \, n^2)} - \frac{e^{-t}}{2\pi n} \right)\frac{dt}{t} = \frac{1}{2\pi n} \mathlarger{\int_0^{\infty}} \left(\frac{1}{1+t^2} - e^{-2 \pi n t}\right)\frac{dt}{t}\]

\[= \frac{1}{2 \pi n} \left[ \mathlarger{\int_0^\infty} \left( \frac{1}{1+t^2}-\cos t \right) \frac{dt}{t} + \mathlarger{\int_0^\infty} \frac{e^{-t}-e^{-2 \pi n t}}{t}dt + \mathlarger{\int_0^\infty}(\cos t - e^{-t})\frac{dt}{t}\right]\] \\

\noindent and by means of 1.7(21) and 1.7(18) this is $(2 \pi n)^{-1}[\gamma + \log(2 \pi n)]$ since we have for the third integral: \\

$\lim \limits_{\delta \, \to \, 0} \, \int_\delta^{\, \infty} \, (\cos t - e^{-t}) \, t^{-1} dt = \lim \limits_{\delta \to 0} \; [\, \text{Ei}(- \delta) - \text{Ci} (\delta) \,] = 0.$ \\

\noindent Thus we have
\begin{align*}
    \log \, \Gamma(x) &= \nicefrac{1}{2} \log(2 \pi) \tag{14}\\
                      &+ \sum_{n=1}^\infty [(2 \pi)^{-1} \, \cos(2 \pi n x) + (\gamma + \log 2 \pi n) \, (\pi n)^{-1} \, \sin(2 \pi n x)], \\
    \log \, \Gamma(x) &= (\nicefrac{1}{2}-x)(\gamma + \log 2) + (1-x) \, \log \pi - \nicefrac{1}{2} \log(\sin \pi x)\\
                      &+ \sum_{n=1}^\infty (\pi n)^{-1} \log n \, \sin(2 \pi n x) & 0 < x < 1,
\end{align*} 

\noindent which is Kummer's series.

A similar representation for $\psi (x)$ is due to Lerch (Nielsen, 1906, p. 204),
\begin{align*}
    \psi (x)&  \, \sin(\pi x) = - \nicefrac{1}{2} \pi \cos(\pi x) - (\gamma + \log 2 \pi) \sin \pi x \tag{15} \\
            &+ \sum_{n=1}^\infty \log \left( \frac{n}{n+1} \right) \sin(2 \pi + 1) \pi x & \, & \; 0 < x < 1.
\end{align*}

\end{document}
  • Note that 2 alignment groups require 3 &. That said, what you want to achieve is not very clear. – Bernard Mar 11 '17 at 15:30
  • Like what? I just tried inserting another & but the thing is still not aligned properly. – Gallifreyan Mar 11 '17 at 15:32
  • Could you post a full compilable code, and explain a little more? It seems you want equation numbering on the left? – Bernard Mar 11 '17 at 15:34
  • Yes, I achieved that with leqno. I can post the code, but it's 64 lines - wouldn't it be too much a mess? – Gallifreyan Mar 11 '17 at 15:35
  • Not really a problem, we'll extract a relevant fraction if necessary. – Bernard Mar 11 '17 at 15:36
2

Here's another attempt. Note that I've tried to make the code more "LaTeX-y" by using instructions such as \subsubsection and letting LaTeX place left-aligned equation numbers. I've gotten rid of the \mathlarger instructions (they're not needed) as well as of most instances of \, (thinspace) -- let TeX take care of the appropriate spacing before and after math operators. I've replaced the two instances of \lim\limits with just \lim (the \limits directives aren't needed). I don't think \nicefrac{1}{2} looks good, at least not with Computer Modern; I recommend using \tfrac instead. I've replaced all instances of \left and \right with \biggl and \biggr, resp. I've gotten rid of the super-kludgy \voffset=0.15in directive and, instead, added the option includehead while loading geometry. Eliminating almost all blank lines also permits omitting most \noindent directives. Finally, I've used \mkern directives to position the 0<x<1 terms.

enter image description here

\documentclass[12pt,leqno]{article}
\usepackage[bottom=0in,top=0.4in,hmargin=1.2in,
   includehead]{geometry} 
\usepackage[fleqn]{amsmath}
   \DeclareMathOperator{\csch}{csch}
\usepackage{fancyhdr,indentfirst} 
   \pagestyle{fancy}
   \fancyhf{} 
   \renewcommand{\headrulewidth}{0pt} 
   \headheight=15pt 
   \chead{GAMMA FUNCTION} 
   \rhead{\arabic{page}}  % page number 
   \lhead{\thesubsubsection} 


\setcounter{section}{1}
\setcounter{subsection}{9}
\setcounter{page}{23}
\setcounter{equation}{13}

\begin{document}
% insert `\boldmath` directive in arg. of '\subsubsection` if '\log\Gamma' should be bolded 
\subsubsection{Kummer's series for $\log \Gamma (z)$} 

The function $\log \Gamma (x)$, $0 < x < 1$, can be expanded in 
a Fourier series. We shall use the known Fourier expansions 
(Bromwich, 1947, pp.\ 356, 393, and 370 respectively):
\begin{align*}
    & \log(\sin\pi x) =  -\log2 -\sum_{n=1}^{\infty}(1/n)\cos(2\pi nx), \\
    & \csch(\tfrac{1}{2}t)\sinh(\tfrac{1}{2}-x)t 
      = 8\pi\sum_{n=1}^{\infty} [n\sin(2\pi nx)]/(t^2 + 4\pi^2 n^2), \\
    & \pi(1-2x) = 2\sum_{n=1}^{\infty}(1/n)\sin(2\pi nx).
\end{align*}

If these are substituted in (7) with $z=x$, we have to evaluate 
the integral 
\begin{multline*}
\int_0^{\infty} \biggl( \frac{2\pi n}{t^2 + 4\pi^2 n^2} - \frac{e^{-t}}{2\pi n} \biggr)\frac{dt}{t} 
= \frac{1}{2\pi n} \int_0^{\infty} \biggl(\frac{1}{1+t^2} - e^{-2 \pi nt}\biggr)\frac{dt}{t}\\
= \frac{1}{2 \pi n} \Biggl[ \int_0^\infty \biggl( \frac{1}{1+t^2}-\cos t \biggr) \frac{dt}{t} 
+ \int_0^\infty \frac{e^{-t}-e^{-2\pi nt}}{t}\,dt 
+ \int_0^\infty(\cos t - e^{-t})\frac{dt}{t}\Biggr]
\end{multline*}
and by means of 1.7(21) and 1.7(18) this is 
$(2\pi n)^{-1}[\gamma+\log(2\pi n)]$ 
since we have for the third integral: 
\[
\lim_{\delta\to 0} \int_\delta^{\infty}  (\cos t-e^{-t}) t^{-1}\, dt = 
\lim_{\delta\to 0} \,[ \text{Ei}(-\delta) - \text{Ci}(\delta)] = 0\,.
\]
Thus we have 
\begin{align}
\log\Gamma(x) &= \tfrac{1}{2} \log(2 \pi) \\
\notag    &+ \sum_{n=1}^\infty [(2\pi)^{-1}\cos(2\pi n x) 
          + (\gamma+\log2\pi n)(\pi n)^{-1}\sin(2\pi nx)], \\
\log\Gamma(x) &= (\tfrac{1}{2}-x)(\gamma+\log2)+(1-x)  
           \log\pi-\tfrac{1}{2}\log(\sin\pi x)\notag\\
\notag   &+ \sum_{n=1}^\infty(\pi n)^{-1}\log n  \sin(2\pi nx) &  \mkern16mu 0 < x < 1, 
\end{align} 
which is Kummer's series.

A similar representation for $\psi(x)$ 
is due to Lerch (Nielsen, 1906, p.\ 204),
\begin{align}
\psi (x)& \sin(\pi x) = -\tfrac{1}{2} \pi\cos(\pi x) 
          - (\gamma+\log2\pi)\sin\pi x \\
\notag  &+ \sum_{n=1}^\infty \log \biggl( \frac{n}{n+1} \biggr) 
          \sin(2\pi+1) \pi x & \mkern145mu 0 < x < 1. 
\end{align}
\end{document}
  • The original clearly doesn't use \boldmath in the section title. The section/subsection number can be added at the top left by suitably redefining \sectionmark and \subsectionmark. – egreg Mar 11 '17 at 20:47
  • @egreg - Thanks. I was looking at the original more closely just now and had also noticed some of these issues. I'll provide suitable updates shortly. – Mico Mar 11 '17 at 20:51
  • @egreg no no no no, this is exactly how this stuff appears in the book! I used \textbf but it didn't work on formulae – Gallifreyan Mar 11 '17 at 20:54
  • 1
    @Gallifreyan - In the (hopefully not entirely vain) hope that you'll learn a few things about LaTeX and its programmability from this exercise, I deliberately provided a bit of material that shows how to make use of LaTeX's machinery. In the short run (i.e., for your assignment), this may well seem like more work than simply engaging in visual formatting. In the longer run, though, I think (hope?) you'll appreciate knowing a few LaTeX-related programming tricks. – Mico Mar 11 '17 at 21:17
  • 1
    Given I am a Physics major, I don't think I have a choice but to learn LaTeX in full :D – Gallifreyan Mar 11 '17 at 21:30
2

Here is my (honest) proposal. I'm not sure I've understood what you want to obtain in full detail, but I did what seemed sensible. In particular, I removed most manual spacings, and defined a macro for the larger integrals, which not include the bounds, but require a manual correction for the placement of the lower bound. Note I gave different alignments for the second lines in eqs 14 and 15, to show the possibilities.

 \documentclass[12pt, leqno]{article} %leqno is to allgn equation labels to left

\usepackage[bottom=0in, top=0.55in,hmargin=1.2in, headheight=15pt, showframe]{geometry} % set margins to look like the original
\usepackage{xfrac, relsize,fancyhdr} % for slanted fractions, bigger integral signs, and some other things
\usepackage[fleqn]{mathtools, nccmath} % for equations flushed to left, among other things
\usepackage[nice]{nicefrac} % for nice slanted fractions

\DeclareMathOperator{\csch}{csch}

\pagestyle{fancy} % I'm not really sure what this does, but the internet guys said to use it ¯ \ _ (ツ) _ / ¯
\fancyhf{} % removes default page number
\renewcommand{\headrulewidth}{0pt} % removes the top line


\fancyhead[C]{GAMMA FUNCTION} % adds header

\newcommand\lint{\mathop{\mathlarger{\int}}\nolimits}

\begin{document}

\rhead{23} % adds page number as a header
\lhead{\textbf{1.9.1}}

\noindent \textbf{1.9.1. \; Kummer's series for \boldmath$\log \Gamma (z)$}\bigskip

The function $\log \Gamma (x)$, $0 < x < 1$, can be expanded in a Fourier series. We shall use the known Fourier expansions (Bromwich, 1947, pp. 356, 393, and 370 respectively):
\begin{align*}
    & \log(\sin\pi x) = - \log 2 - \sum_{n=1}^{\infty} \, (1/n) \cos (2\pi n x), \\
    & \csch (\mfrac{1}{2} \, t) \, \sinh (\mfrac{1}{2}-x)t = 8 \pi \, \sum_{n=1}^{\infty} [n \; \sin(2\pi n x)]/(t^2 + 4{\pi }^2 n^2), \\
    & \pi (1 - 2x) = 2 \sum_{n=1}^{\infty} (1/n) \sin(2 \pi nx).
\end{align*}

If these are substituted in (7) with $z=x$, we have to evaluate the integral
%
\begin{multline*}
    \lint_{\mkern-15mu 0}^{\infty} \biggl(\frac{2\pi n}{t^2 + 4{\pi }^2 \, n^2)} - \frac{e^{-t}}{2\pi n} \biggr)\frac{dt}{t} = \frac{1}{2\pi n} \lint_{\mkern-15mu 0}^{\infty}\biggl(\frac{1}{1+t^2} - e^{-2 \pi n t}\biggr)\frac{dt}{t} \\
     = \frac{1}{2 \pi n} \left[ \lint_{\mkern-15mu 0}^\infty \biggl( \frac{1}{1+t^2}-\cos t \biggr) \frac{dt}{t}
     + \lint_{\mkern-15mu 0}^\infty \frac{e^{-t}-e^{-2 \pi n t}}{t}dt %
     + \lint_{\mkern-15mu 0}^\infty (\cos t - e^{-t})\frac{dt}{t}\right]
\end{multline*}%
and by means of 1.7(21) and 1.7(18) this is $(2 \pi n)^{-1}[\gamma + \log(2 \pi n)]$ since we have for the third integral:
%
\[ \lim_{\delta \to 0} \int_\delta^{\infty}(\cos t - e^{-t}) \, t^{-1} dt = \lim_{\delta \to 0} \bigl [\text{Ei}(- \delta ) - \text{Ci} (\delta ) \bigr] = 0. \]
%
 Thus we have
\begin{flalign} \tag{14}
\log \Gamma (x) &= \begin{aligned}[t] & \nicefrac{1}{2} \log(2 \pi ) & \\
& \mathrlap{+ \sum_{n=1}^\infty [(2 \pi )^{-1} \, \cos(2 \pi n x) + (\gamma + \log 2 \pi n) \, (\pi n)^{-1} \, \mathrlap{\sin(2 \pi n x)]},}
\end{aligned} &
\\
\notag
\log \Gamma (x) &= \begin{aligned}[t] & (\nicefrac{1}{2}-x)(\gamma + \log 2) + { (1-x) \, \log \pi -\nicefrac{1}{2} \log(\sin \pi x)}\\
&+ \sum_{n=1}^\infty (\pi n)^{-1} \log n \, \sin(2 \pi n x)
\end{aligned} %
& & \begin{aligned}[t]
& \mbox{}\\[2ex] 0 < x < 1, \end{aligned}
\end{flalign}
%
which is Kummer's series.

A similar representation for $\psi (x)$ is due to Lerch (Nielsen, 1906, p. 204),%
\begin{flalign}\tag{15}%
    \psi (x)\sin(\pi x)&= - \nicefrac{1}{2} \pi \cos(\pi x) - (\gamma + \log 2 \pi ) \sin \pi x \\
     & + \sum_{n=1}^\infty \log \left( \frac{n}{n+1} \right) \sin(2 \pi + 1) \pi x % This is ugly, but there's nothing I could do
     & & 0 < x < 1.\notag
\end{flalign}

\end{document}

enter image description here

  • This is weird - it is still not left enough when I compile it – Gallifreyan Mar 11 '17 at 17:27
  • What should be more to the left? The equation numbers are at the left margin. I don't see what you mean. Equation numbers in the left margin, and body of the equation beginning at the left margin? – Bernard Mar 11 '17 at 17:33
  • Sorry :D I meant right. 0<x<1. should be on the right, directly under 0<x<1, in (14). It is correct on your render, but not on mine. – Gallifreyan Mar 11 '17 at 17:49
  • @Gallifreyan: I have a solution with the flalign environment. That's the first I thought of, but it seemed to be conflicting with the leqno option – probably some bug of amsmath. However, loading mathtools (which fixes some of these bugs) in the place of amsmath solves the problem. Please see my updated answer. Is it more like you want? – Bernard Mar 11 '17 at 20:43
  • 1
    @Mico: Problem solved. Just add a second ampersand on the first line of flalign. – Bernard Mar 12 '17 at 12:58

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.