5

Is there an environment (or standard framework) to typeset a (single line) displayed equation with a "short" quantification that gives the following result? enter image description here That is, the "main" part of the equation is centered (as if nothing else were there), and the quantifier part is aligned to the left with some indentation. I don't think this is supposed to work for longer strings, and I am not looking for a solution that does.

I have found similar questions here (e.g. equation center, quantifier push right), but solutions like

\begin{flalign}
 \forall x \in X  &&&  P(x)  &&
\end{flalign}

are not what I'm looking for since $P(x)$ is not centred within the page, and $\forall x\in X$ is not indented. Adding

\begin{flalign}
\qquad \forall x \in X  &&&  P(x)  &&
\end{flalign}

does seem to get the desired indentation, but $P(x)$ is now even less centred.

  • 2
    your image shows an unnumbered equation but your code fragments use flalign rather than flalign* so produce numbered equations. (This has a bearing on the answers see for example Mico's comment on @Bernard's question which wouldn't apply in the unnumbered case) – David Carlisle Dec 16 '18 at 21:42
  • That's true, and I apologise for the confusion. As I mentioned in a comment under Mico's answer, I was looking for a solution that would support equation numbering. – prt13463 Dec 16 '18 at 23:13
3

Here's a proposal that does the centering when feasible, resorting to standard centering otherwise. (Thanks to Mico for the coding.)

\documentclass{book}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{environ}

\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]

\newcommand\bff{\mathbf{f}}
\newcommand\bfg{\mathbf{g}}

\makeatletter
\NewEnviron{quantifiedequation}[1]{% #1 is the quantifiers
  \begin{equation}
  \expandafter\make@quantifiedequation\expandafter{\BODY}{#1}
  \end{equation}
}
\NewEnviron{quantifiedequation*}[1]{% #1 is the quantifiers
  \begin{equation*}
  \expandafter\make@quantifiedequation\expandafter{\BODY}{#1}
  \end{equation*}
}
\newcommand{\make@quantifiedequation}[2]{%
  \m@th % remove mathsurround
  \sbox\z@{$\displaystyle#2$}% measure the quantifiers
  \sbox\tw@{\let\label\@gobble$\displaystyle#1$}
  \ifdim\dimexpr 1em+\wd\z@+0.5\wd\tw@+2em>0.5\displaywidth
    % centering is not possible
    #2\qquad#1
  \else
    \makebox[0pt][r]{%
      \makebox[\dimexpr0.5\displaywidth-0.5\wd\tw@][l]{\quad\box\z@}%
    }#1
  \fi
}
\makeatother

\begin{document}
\setcounter{chapter}{1}
\setcounter{section}{1}
\setcounter{defn}{12}

\begin{defn}
Let $M$ be a manifold. A \emph{derivation} at a point $p\in M$ 
is an $\mathbb{R}$-linear map $X\colon C^\infty(p)\to\mathbb{R}$ 
which satisfies the \emph{Leibniz rule}
\begin{quantifiedequation*}{\forall\,\bff,\bfg\in C^\infty(p)}
    X(\bff\bfg)=\bff(p)X(\bfg)+\bfg(p)X(\bff)
\end{quantifiedequation*}
\end{defn}

\begin{defn}
Let $M$ be a manifold. A \emph{derivation} at a point $p\in M$ 
is an $\mathbb{R}$-linear map $X\colon C^\infty(p)\to\mathbb{R}$ 
which satisfies the \emph{Leibniz rule}
\begin{quantifiedequation}{\forall\,\bff,\bfg\in C^\infty(p)}
    X(\bff\bfg)=\bff(p)X(\bfg)+\bfg(p)X(\bff)
    \label{qeq}
\end{quantifiedequation}
\end{defn}

Here's the reference \eqref{qeq}.

\begin{defn}
Let $M$ be a manifold. A \emph{derivation} at a point $p\in M$ 
is an $\mathbb{R}$-linear map $X\colon C^\infty(p)\to\mathbb{R}$ 
which satisfies the \emph{Leibniz rule}
\begin{quantifiedequation*}{\forall\,\bff,\bfg\in C^\infty(p)}
    X(\bff\bfg)=\bff(p)X(\bfg)+\bfg(p)X(\bff)
    +\bff(p)X(\bfg)+\bfg(p)X(\bff)
\end{quantifiedequation*}
\end{defn}
\end{document}

enter image description here

4

I'm not aware of a ready-made environment or "standard framework" that does exactly what you're looking to achieve. However, it's not too much work to create a custom macro that gets the job done.

enter image description here

Note that the macro \quant -- you're obviously free to choose a different name for this macro -- takes 2 arguments: the quantifier (which is indented by \quad from the left-hand edge of the text block; feel free to change the indentation amount) and the actual equation. Do note that because the equation is centered exactly on the line, the whitespace to its left and right won't be of equal length (since the whitespace on the left is reduced by the presence of the quantier).

Observe that equation numbering isn't an option, but then I got the impression that automatic equation numbering isn't a requirement. Do advise if it is.

Observe also that if quantifier and/or the equation are quite long, they will likely overlap in a very unsightly way. I gather, though, that this is not likely to be an issue.

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,amsthm}
\theoremstyle{definition}
\newtheorem{defn}{Definition}
\counterwithin{defn}{section}

%% Set up a macro called "\quant":
\newcommand{\quant}[2]{\par%
   \vspace{\abovedisplayskip}%
   \noindent%
   \parbox{0pt}{\mbox{\quad$\displaystyle #1$}}
   \hfil $\displaystyle #2$ \hfill\par
   \vspace{\belowdisplayskip}}

\newcommand\bff{\mathbf{f}}
\newcommand\bfg{\mathbf{g}}

\begin{document}
\setcounter{chapter}{1}
\setcounter{section}{1}
\setcounter{defn}{12}

\begin{defn}
Let $M$ be a manifold. A \emph{derivation} at a point $p\in M$ 
is an $\mathbb{R}$-linear map $X\colon C^\infty(p)\to\mathbb{R}$ 
which satisfies the \emph{Leibniz rule}
\quant{\forall\,\bff,\bfg\in C^\infty(p)}{%
    X(\bff\bfg)=\bff(p)X(\bfg)+\bfg(p)X(\bff)}
\end{defn}
\end{document}
  • Thank you. Actually, yes, it's not a huge deal-breaker, but it would be helpful if this supported equation numbering. I understand that egreg improved your code to implement this. Thanks to both! – prt13463 Dec 16 '18 at 22:42
2

How about this?

\documentclass{article}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}
 \usepackage{mathtools}

\begin{document}

\begin{flalign}
\quad \mathrlap{\forall x \in X} &&& P(x) &&
\end{flalign}

\end{document} 

enter image description here

  • With this approach, P(x) won't be place exactly in the center of the entire line. Instead, it will be centered on the line segment that stretches from the left-hand edge of the text block to (but not including) the equation number. Is there a way to achieve full centering (which seems to be one of the OP's formatting objectives)? – Mico Dec 16 '18 at 21:06
  • 1
    @Mico: Strangely, my code is the closest to the expected result (lengths difference < 1pt between both blank spaces). Adding a \quadon the right side makes the difference greater (6 to 7 pt). So clearly there are placement details I have no control on. – Bernard Dec 16 '18 at 21:36
  • Although I have accepted egreg's answer, this also works well and produces the desired output. – prt13463 Dec 16 '18 at 23:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.