# Indentation of equation numbers from left margin

I seek help in finding an efficient way, upon creating a symbolic or textual expression by means of a command, to indent from the left margin not only the expression but its parenthetically enclosed number. (Motivation for this consists in the editorial convention for logic that presents the premises and conclusion of a deductive argument, whether expressed in symbolic form or prose, as a sequence in which each statement occupies an indented line beginning with an assigned number.) The goal is to indent the numbers from the left margin by n pts. and to indent the statements by m pts. for 0 < n < m. Usually n is at least as great as \parindent. For example, n = 32, m = 48.

I'm a neophyte at TeX, and this is my first posting here. Learning from various sources, I began by trying the following.

\documentclass[12pt,letterpaper,leqno,fleqn]{article}
\usepackage{amsmath}
\usepackage{latexsym,amssymb}
\setlength{\mathindent}{24pt}
\newcommand{\texteq}[1]{$$\text{\parbox{0.85\textwidth} {#1}}$$}
\begin{document}
## [A] ##
$$p \implies q$$
$$p$$
$$∴ q$$
## [B] ##
\texteq{All bachelors are unmarried.}
\texteq{Jones is a bachelor.}
\texteq{∴ Jones is unmarried.}

\end{document}


[A] yields the following.

Prior text

(1) 𝑝 ⟹ 𝑞

(2) 𝑝

(3) ∴𝑞

Subsequent text

[B] yields

Prior text

(4) All bachelors are unmarried.

(5) Jones is a bachelor.

(6) Therefore Jones is unmarried.

Subsequent text

What I've tried to indicate above is that neither [A] nor [B] indents the numbers. They do place the expressions leftward from center, and at a suitable distance from the closing parens. Both also introduce excessive vertical space (about three lines, two too many) not shown above.

About [B], I mention that, wishing the opportunity for purely textual numbered expressions and statements, I took it that the \newcommand line above accomplished that, but observe that if '\text' is deleted therefrom, the result is unaffected. A further puzzle is the enclosing punctuation of '\text{\parbox{0.85\textwidth}.' So far as I can tell, this lacks one closing brace (and perhaps one at the beginning). I must not understand what is going on in this command. All attempts to alter the punctuation issue in error messages unsolvable except by restoring the quoted code.

I've tried to find ways to insert into the code for [A] and [B] some settings for leftmargin, rightmargin (whose widening also could be desirable in a given case), parsep, topsep, and more. I've looked for other approaches to solving the problem. None of the foregoing ploys have worked.

I've read of the align and multiline environments, but don't know whether or how to implement them for the present purpose.

An earlier posting evoked a solution for the complementary problem of indenting numbers (though not expressions) from the right margin (Controlling exact position of equation numbers). I do not sufficiently understand the programming code used there so as to glimpse whether it would be adaptable for use in the present context.

Lastly, one might relegate the present task to an enumeration or custom list, but that would forego the equation environment's typesetting capabilities for expressions written in symbolic logic, as well as the uncomplicated consecutivity of equation numbering notwithstanding interspersed main body text.

Thanks to @Mico for your answer. I appreciate your accommodating my preference by specifying \displaystyle. I've found in experimenting that not only does the list work, but it appears that the labelindent option directed at the heart of my question, seems superfluous, as leftmargin seems to control displacement of labels and text from the left. There remains for me a preference for the equation environment as follows. I read one of your postings (Show inline math as if it were display math) in which you wisely admonished, on grounds of typographical appearance, against forcing features of display style on inline expressions. A publisher's production staff, with a keen eye for such things, might hold the same view, and at first glance, find code that imposes it an auctorial nuisance. They commonly emphasize that they prefer a file with as little formatting code as possible. If it suffices to use standard commands leqno and fleqn with a command to indent parenthetical numbers from the left, that might aid interactions with the publisher. In logic it is also valuable to produce annotations (usually premise numbers) to the right of enumerated sentences, which the mathematical 'align' environment is well-equipped to do, but I'm unclear whether that would work inline. I wonder also if there may flow from the equation treatment other benefits of which I am unaware. If you could espy a way to effect that treatment, it would be most appreciated.

I thank @skpblack for this solution, which works beautifully. After considerable time studying it to discern the artistry, and exploration of changing the variables, I have come to understand some of what the code does, but would like to pose the following for clarification. (1) I wonder what [2][0.5] instructs. I see that changing 0.5 varies the distance between expression and annotation, and how far rightward annotation extends. The distance 0.5 gives a well-proportioned result, thank you. I also see that any substitute for 2 wreaks havoc. (2) Notwithstanding your two distance . . . comments, numbersep appears to be distance of numbers from left margin, and statementsep the distance between numbers and statements. So I have set them at 40pt and 28pt, respectively. (3) Noticing the alternation between \text and \texteqn in the premises, I found the commands to be functionally interchangeable everywhere except in the case of \texteq[0.4]. What is going on in the last line but not in the other lines? Here I do not understand the function of 0.4. Is it truly a matter of indifference which command one uses? (4) I am unclear what it means to align "by top." Upon deleting [t], the outcome doesn't appear to change. (5) If a document had equations for which one preferred the standard centered, reqno presentation, I gather that \everydisplay{\displayindent=\numbersep} would impose on those equations the leqno, fleqn presentation that you've astutely encoded for indentation. Does it make sense to house your code in the definition of another environment for numbered sentences, with separate counter, so as to leave equations undisturbed? (6) If it were desired to restart numbering at the end of an argument, I infer that one could write \setcounter{equation}{0} before the next, unless you recommend another way. (7) I wonder if one could add tags to numbered sentences, perhaps on the right in place of annotations. (8) I gather that the \mathindent line overrides any prior such command in the preamble. Should I delete any prior such command?

A great virtue of the products of what you've written is the absence of excessive vertical spacing. More generally, the gather solution is beautifully simple, and the align merely appears a little less so for scattered ampersands. Both signify deep insight, for which I greatly thank you.

• There are a number of ways to control the positioning of a number. \makebox[width][r]{\thenumber}\hspace{gap} where width and gap are appropriate lengths is one. In fact, this is almost precisely how enumerate works, using \labelwidth and \labelsep. Why can't you use $\displaystyle ...$ for single line math? – John Kormylo Aug 12 '17 at 3:23
• Off-topic: The latexsym package has been deprecated since about 1994, i.e., when LaTeX2.09 was superseded by LaTeX2e. As you're loading the amssymb package, there can be no justification for loading latexsym as well. – Mico Aug 12 '17 at 6:03
• I thank John for that guidance. I'd like to experiment with the \makebox code, but don't know where to insert it. Could you advise on the full command? I was unfamiliar with \displaystyle, but see from Gratzer that it controls font size. Murphy's law prevailing, I would have some multiline entries. I thank Mico for the advice against using latexsym. I have to study his answer with care to understand it. – Louis Aug 12 '17 at 17:54
• @johnkormylo, since I did not understand, when posting a reply to your comment, the procedure for notifying the commentator of such a reply, I write this to mention the posting of my reply. – Louis Aug 13 '17 at 6:10
• \makebox would start the line, although it is often used with \llap{...}. The equation environment is in \displaystyle by default, and $...$ is in \textstyle by default. The most apparent difference is how they affect things like summation signs and integrals. – John Kormylo Aug 13 '17 at 13:41

Despite your stated preference for a numbered-equation type solution, I think you're better off creating a custom enumerated environment, using the machinery of the enumitem package. It's a very powerful package that lets you customize lists in just about any way imaginable -- and probably a few more ways you couldn't imagine... :-)

The following answer shows how some of the customization may be tackled. Note that it's no problem at all to restart the numbering of the list after some intervening material has occurred. The enumerated items can also be cross-referenced using the usual LaTeX tools.

\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath,amssymb,lipsum}
\newcommand\logic[1]{$\displaystyle#1$} % helper macro

\usepackage{enumitem} % see https://www.ctan.org/pkg/enumitem
% Create a custom enumerated environment called "mylist":
\newlist{mylist}{enumerate}{1} % Depth: just 1 level
\setlist[mylist]{label=(\arabic*), % parentheses around labels; arabic numerals
ref=\arabic*,     % no parentheses in cross-references
labelindent=2\parindent, % distance to left-hand edge of text block
leftmargin = !, % compute as residual
rightmargin=1\parindent, % distance to right-hand edge of text block
resume % resume numbering automatically
}

% And, just for this example:
\usepackage[noabbrev]{cleveref} % package for advanced cross-referencing
\crefname{mylisti}{item}{items} % choose singular & plural names

\begin{document}
\noindent\dots
\begin{mylist}
\item \logic{p \implies q}
\item \logic{p}
\item \logic{\therefore\ q} \label{item:x}
\end{mylist}
\dots
\begin{mylist}  % numbering is resumed automatically
\item All bachelors are unmarried.
\item Jones is a bachelor.
\item \logic{\therefore\ \text{Jones is unmarried.}}
\item \lipsum*[2] \label{item:y} % item with filler text
\end{mylist}

\hrule % to illustrate width of text block

\bigskip

% Use "\cref" to create cross-references to multiple items:
Cross-references to \cref{item:x,item:y}.

\end{document}


If you insist in use math environments such as equation, gather or align due to its ability to align in two or more columns (to put anotations) its possible adjust these indents with the parameters \displayindent and \mathindent, \displaywidth measures width of a displayed equation. it's very important to use leqno and fleqn options to keep numbers at left and the displayed equations not centered but aligned at left by \mathindent.

In this case you can use the environments gather of align (if you requires to align or put anotations in other column). Morever that reduce space inter lines that if you use several equation environments.

\documentclass[12pt,letterpaper,leqno,fleqn]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\newcommand{\texteq}[2][0.5]{\text{\parbox[t]{#1\displaywidth}{#2}}}
\newcommand{\lther}{\mathord{\therefore}\mskip\thickmuskip}
%-----------------------------------------------------------------
% Lengths to control indents of 'equation numbers' and statements
\newlength{\numbersep}          % Distance of number at left margin
\newlength{\statementsep}       % Distance of statement at left margin
\setlength{\numbersep}{\parindent}  % n
\setlength{\statementsep}{15mm}     % m (0<n<m)
%-----------------------------------------------------------------
\everydisplay{\displayindent=\numbersep}
\setlength{\mathindent}{\statementsep}

\begin{document}
\noindent\hrulefill\\
Prior text
\begin{align}
& p\implies q   &&\text{First premise.}\label{p1}\\
& p             &&\texteq[0.4]{Second premise.}\label{p2}\\
&\lther q       &&\texteq{One very large conclusion that we can construct of premises \eqref{p1} and \eqref{p2}.}
\end{align}
Subsequent text. Now we can construct the following reasoning
\begin{gather}
\text{All bachelors are unmarried.}\\
\texteq{Jones is a bachelor.}\\
\lther\text{Jones is unmarried.}
\end{gather}

\end{document}


I modified your command \texteq for to write paragraphs in a equation environment with a optional argument to fix the width and [t] option to align by top.