1

I have the following minimal latex code on overleaf in an attempt to create a 12pt, 1in margin, letter-size document in Times New roman:

\documentclass[12pt, letterpaper, fleqn, notitlepage]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{newtxtext}
\usepackage{color}
\usepackage{amsmath,amssymb,amsfonts,amsthm}

\begin{document}
$$Entropy(\text{D}) = -\sum\limits_{d \in D} p(d) \log_{2}p(d) $$
$$Entropy(\text{S}) = p(s+)\Bigg [ -\sum\limits_{d \in D} p(d | s+) \log_{2}p(d | s+)\Bigg ] \\
+ p(s-)\Bigg [-\sum\limits_{d \in D} p(d | s-) \log_{2}p(d | s-)\Bigg ]$$
\end{document}

And I'm trying to simply left align all of the equations and hide equation numbers.

Here is what I have tried without success:

  • fleqn in document options
  • \begin{align} and \end{align}
  • \begin{flalign*} and \end{flalign*}
  • \setlength\mathindent{0pt}

Any help would be appreciated. Thank you.

1
1

Like this?

enter image description here

(red lines indicate text borders)

\documentclass[12pt, fleqn]{article}
\usepackage[letterpaper, 
            margin=1in]{geometry}
\usepackage{newtxtext}
\usepackage{mathtools,amssymb,amsthm}
\setlength{\mathindent}{0pt}  % <----

\begin{document}
    \[
\mathrm{Entropy}(D) = -\sum\limits_{d \in D} p(d) \log_{2}p(d) 
    \]
some text?
    \[
\mathrm{Entropy}(S) 
    \begin{multlined}[t][0.5\linewidth]
    = p(s+)\Bigg[-\sum\limits_{d \in D} p(d | s+) \log_{2}p(d | s+)\Bigg]    \\
+ p(s-)\Bigg[-\sum\limits_{d \in D} p(d | s-) \log_{2}p(d | s-)\Bigg]
    \end{multlined}
    \]
\end{document}

Note, in document code is corrected errors in equation too.

0

You can accomplish this with the align* environment, the fleqn and alignedleftspaceno options of amsmath, and a \@mathmargin of zero. To break a long equation, insert a split.

If you just want equations flush left without alignment points, you can use the lgather environment from mathtools.

The fleqn option should go to amsmath or whatever package loads it. You should only give it to the document class if you are using an AMS class, such as amsbook.

It sets equations left, with an indentation set by \@mathmargin. Setting it to 0pt gets you flush left.

\documentclass[12pt, letterpaper, notitlepage]{article}
\usepackage[margin=1in]{geometry}
\usepackage{iftex}
\usepackage{xcolor}
\usepackage[fleqn, alignedleftspaceno]{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\ifPDFTeX
  \usepackage{newtxtext, newtxmath}
\else
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale = MatchLowercase}
  \setmainfont[Scale = 1.0]{TeX Gyre Termes}
  \setmathfont{TeX Gyre Termes Math}
\fi

% Set the left margin used by fleqn to 0pt.
\makeatletter
\AtBeginDocument{\@mathmargin0pt\relax}
\makeatother

\DeclareMathOperator{\Entropy}{Entropy}

\begin{document}
\begin{align*}
  \Entropy(\mathrm{D}) &= -\sum\limits_{d \in D} p(d) \log_{2}p(d) \\
  \intertext{Oh, and by the way:}
  \begin{split}
  \Entropy(\mathrm{S}) &=
     p(s+)\Bigg [ -\sum\limits_{d \in D} p(d | s+) \log_{2}p(d | s+)\Bigg ] \\
     &\hphantom{=} + p(s-)\Bigg [-\sum\limits_{d \in D} p(d | s-) \log_{2}p(d | s-)\Bigg ]
  \end{split}
\end{align*}
\end{document}

Equation sample

I took a few liberties, such as setting the math font to match Times, defining an operator \Entropy that works like \log or \sin, and changing \text (which matches the current formatting of the surrounding text) to \mathrm (upright letters in math mode).

The alignment of the second line of the split equation is very flexible. You can for example remove the \hphantom to align the + with the=` above, or add more space after it.

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.