4

I am having the exact same problem as this (closed) question - but I have ideas as to what might be causing the problem in my case

\documentclass[12pt,a4paper]{article}
\usepackage{mathtools}

\begin{document}
\begin{align}
\mathcal{B}_{x}=\frac{\splitfrac{\Pr\left(\tau_{i}\in[x, x+\delta)|\omega_{x+\delta}=1, \tau_{i}\not\in [x-\delta, x)\right)^{m}}{\Pr\left(\tau_{i}\not\in[x, x+\delta)|\omega_{x+\delta}=1, \tau_{i}\not\in [x-\delta, x)\right)^{k-m-1}}}{\splitfrac{\Pr(\tau_{i}\in[x, x+\delta)|\omega_{x+\delta}=0, \tau_{i}\not\in [x-\delta, x))^{m}}{\Pr\left(\tau_{i}\not\in[x, x+\delta)|\omega_{x+\delta}=0, \tau_{i}\not\in [x-\delta, x)\right)^{k-m-1}}}
\end{align}
\end{document}

When I run the code as it is above, I get my desired output: enter image description here

However, when I run it with the entire preamble that I am using for a longer document, I get extra "1" characters

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amsthm,amssymb,apacite,graphicx, verbatim,upref,paralist,indentfirst}
\usepackage{setspace}
\usepackage{breqn}
\allowdisplaybreaks
\usepackage{graphicx}
\usepackage{mathrsfs}
\usepackage{mathtools}
\usepackage{enumerate}
\graphicspath{ {./images/} }
\onehalfspacing
\usepackage{float}
\setlength{\parskip}{2pt}%

\begin{document}
\begin{align}
\mathcal{B}_{x}=\frac{\splitfrac{\Pr\left(\tau_{i}\in[x, x+\delta)|\omega_{x+\delta}=1, \tau_{i}\not\in [x-\delta, x)\right)^{m}}{\Pr\left(\tau_{i}\not\in[x, x+\delta)|\omega_{x+\delta}=1, \tau_{i}\not\in [x-\delta, x)\right)^{k-m-1}}}{\splitfrac{\Pr(\tau_{i}\in[x, x+\delta)|\omega_{x+\delta}=0, \tau_{i}\not\in [x-\delta, x))^{m}}{\Pr\left(\tau_{i}\not\in[x, x+\delta)|\omega_{x+\delta}=0, \tau_{i}\not\in [x-\delta, x)\right)^{k-m-1}}}
\end{align}
\end{document}

enter image description here

I am suspecting that there is some "contamination" from other packages in the preamble that are producing these unwanted "1" characters. Is there anything I can do to remove these unwanted "1"s? Is there a way I can do this without removing other packages from the preamble, as this may affect other formulae that I have in the document.

Edit: I suspect it is this line in the preamble that is causing the "1" to appear:

    \usepackage{breqn}

When I remove it from the preamble, the 1's disappear. Is there a way to remove the 1's without removing this line from the preamble?

4

A really minimal example is

\documentclass{article}
\usepackage{breqn}

\begin{document}
\[
\genfrac{}{}{0pt}{1}{A}{B}
\]
\end{document}

that typesets

enter image description here

whereas it typesets as expected if breqn is changed into amsmath. Note that \splitfrac is just a thin layer around \genfrac.

Oh, wait! How does the minimal example compile? Isn't \genfrac defined by amsmath that isn't loaded? Yes, that's true. Besides other damages, breqn seizes the initiative to define (or redefine) \genfrac. But it does it wrong. The definition is in mathstyle.sty

 145   │ \DeclareRobustCommand\genfrac[6]{%
 146   │   {#1\fracstyle
 147   │     {\begingroup #5\endgroup
 148   │       \csname @@\ifx\maxdimen#4\maxdimen over\else above\fi
 149   │         \if @#2@\else withdelims\fi\endcsname #2#3#4\relax
 150   │      #6}%
 151   │   }%
 152   │ }

and #2#3#4\relax should be #2#3\relax. The modified macro gives the expected result:

\documentclass{article}
\usepackage{breqn}
\usepackage{regexpatch}

\makeatletter
\xpatchcmd{\genfrac}{#4\relax}{\relax}{}{}
\makeatother

\begin{document}
\[
\genfrac{}{}{0pt}{1}{A}{B}
\]
\end{document}

Without regexpatch, your document should look as follows:

\documentclass{article}
\usepackage{mathtools}
\usepackage{breqn}

\makeatletter
\DeclareRobustCommand\genfrac[6]{%
  {#1\fracstyle
  {\begingroup #5\endgroup
     \csname @@\ifx\maxdimen#4\maxdimen over\else above\fi
     \if @#2@\else withdelims\fi\endcsname #2#3\relax
     #6}%
  }%
}
\makeatother

\begin{document}

\begin{equation}
\mathcal{B}_{x}=
  \frac{
    \splitfrac{
      \Pr\left(\tau_{i}\in[x, x+\delta)|\omega_{x+\delta}=1,
      \tau_{i}\not\in [x-\delta, x)\right)^{m}
    }{
      \Pr\left(\tau_{i}\not\in[x, x+\delta)|\omega_{x+\delta}=1,
      \tau_{i}\not\in [x-\delta, x)\right)^{k-m-1}
    }
  }{
    \splitfrac{
      \Pr(\tau_{i}\in[x, x+\delta)|\omega_{x+\delta}=0,
      \tau_{i}\not\in [x-\delta, x))^{m}
    }{
      \Pr\left(\tau_{i}\not\in[x, x+\delta)|\omega_{x+\delta}=0,
      \tau_{i}\not\in [x-\delta, x)\right)^{k-m-1}
    }
  }
\end{equation}

\end{document}

enter image description here

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.