TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am formatting a long formula (the result of a computation) using breqn. It looks great if I replace the = sign with an operator like \times. But when I put the = in, I don't like the output.

I think I should be able to make breqn treat '=' the same as '+' by doing something like

\DecalareMathSymbol{\myequals}{\mathbin}{sym-font?}{slot?}

and then using \myequals instead of =. Unfortunately, I don't know what to put for sym-font and slot to get the = sign.

How can I do this?

Here is a MWE (kind of long, but I need the formula to be long for the results to be noticable) (here is an overleaf link to the example):

\documentclass{amsart}
\usepackage{breqn}

\newcommand{\longformula}{
1 + \left(-\frac{1}{6} r^{3} + \frac{1}{6} r\right)z^{2} +
\left(\frac{17}{40} r^{5} - \frac{5}{8} r^{3} + \frac{1}{5}
r\right)z^{3} + \left(-\frac{631}{630} r^{7} + \frac{1}{72} r^{6} +
\frac{88}{45} r^{5} - \frac{1}{36} r^{4} - \frac{209}{180} r^{3} +
\frac{1}{72} r^{2} + \frac{29}{140} r\right)z^{4} +
\left(\frac{171215}{72576} r^{9} - \frac{17}{240} r^{8} -
\frac{69619}{12096} r^{7} + \frac{7}{40} r^{6} + \frac{16979}{3456}
r^{5} - \frac{11}{80} r^{4} - \frac{31259}{18144} r^{3} + \frac{1}{30}
r^{2} + \frac{13}{63} r\right)z^{5} + \left(-\frac{18684667}{3326400}
r^{11} + \frac{155581}{604800} r^{10} + \frac{597209}{36288} r^{9} -
\frac{1699}{2240} r^{8} - \frac{5513891}{302400} r^{7} +
\frac{23033}{28800} r^{6} + \frac{114685}{12096} r^{5} -
\frac{2669}{7560} r^{4} - \frac{519509}{226800} r^{3} + \frac{229}{4200}
r^{2} + \frac{281}{1386} r\right)z^{6} +
\left(\frac{401297449}{29652480} r^{13} - \frac{8914439}{10886400}
r^{12} - \frac{528153667}{11404800} r^{11} + \frac{30585833}{10886400}
r^{10} + \frac{4352347}{69120} r^{9} - \frac{13405099}{3628800} r^{8} -
\frac{44899771}{1036800} r^{7} + \frac{25156259}{10886400} r^{6} +
\frac{817639}{51840} r^{5} - \frac{1859441}{2721600} r^{4} -
\frac{339287}{118800} r^{3} + \frac{1433}{18900} r^{2} + \frac{85}{429}
r\right)z^{7} + \left(-\frac{448937586017}{13621608000} r^{15} +
\frac{545510843}{223534080} r^{14} + \frac{200873307991}{1556755200}
r^{13} - \frac{4578488741}{479001600} r^{12} -
\frac{41467078967}{199584000} r^{11} + \frac{653808103}{43545600} r^{10}
+ \frac{13531857077}{76204800} r^{9} - \frac{1224530857}{101606400}
r^{8} - \frac{4709184889}{54432000} r^{7} + \frac{56484901}{10886400}
r^{6} + \frac{119034073}{4989600} r^{5} - \frac{67641247}{59875200}
r^{4} - \frac{7752863023}{2270268000} r^{3} + \frac{1123657}{11642400}
r^{2} + \frac{9949}{51480} r\right)z^{8} +
\left(\frac{1067238963813721}{13173608448000} r^{17} -
\frac{4580572146421}{653837184000} r^{16} -
\frac{1868424788136953}{5230697472000} r^{15} +
\frac{1008805230793}{32691859200} r^{14} +
\frac{992904065416223}{1494484992000} r^{13} -
\frac{101113443793}{1796256000} r^{12} -
\frac{272962348105847}{402361344000} r^{11} +
\frac{25120947101}{457228800} r^{10} +
\frac{60592820342221}{146313216000} r^{9} -
\frac{141153688681}{4572288000} r^{8} -
\frac{4423647350867}{28740096000} r^{7} + \frac{7144205161}{718502400}
r^{6} + \frac{44170826140139}{1307674368000} r^{5} -
\frac{15354074077}{9081072000} r^{4} - \frac{36013858967}{9081072000}
r^{3} + \frac{48901}{420420} r^{2} + \frac{6871}{36465} r\right)z^{9} +
\left(-\frac{174424081161393493}{868893574348800} r^{19} +
\frac{740164886921567}{37661021798400} r^{18} +
\frac{525222462909510739}{533531142144000} r^{17} -
\frac{1509433069953143}{15692092416000} r^{16} -
\frac{32583814614724447}{15692092416000} r^{15} +
\frac{250692752979619}{1255367393280} r^{14} +
\frac{16579532320075783}{6725182464000} r^{13} -
\frac{829530467198351}{3621252096000} r^{12} -
\frac{4367664389322431}{2414168064000} r^{11} +
\frac{13899331735211}{87787929600} r^{10} +
\frac{2045747884459907}{2414168064000} r^{9} -
\frac{40609260170929}{603542016000} r^{8} -
\frac{423655761620591}{1681295616000} r^{7} +
\frac{40245068798999}{2353813862400} r^{6} +
\frac{29792663200381}{653837184000} r^{5} -
\frac{96567618673}{40864824000} r^{4} - \frac{115983959747}{25729704000}
r^{3} + \frac{6135329}{45405360} r^{2} + \frac{84883}{461890}
r\right)z^{10} 
+ O(z^{11})
}

\begin{document}
looks good but I want the $\times$ to be an $=$:
\begin{dmath*}
A(z) \times \longformula
\end{dmath*}

looks bad to me:
\begin{dmath*}
A(z) = \longformula
\end{dmath*}
\end{document}
share|improve this question
    
Welcome! You could say \newcommand*\myequals{\ensuremath{\mathbin{=}}} maybe. But I'm not sure that's right. – cfr Mar 23 at 18:04
up vote 4 down vote accepted

breqn already provides for this:

\begin{dmath*}
A(z) \hiderel{=} \longformula
\end{dmath*}

enter image description here

share|improve this answer
    
I am accepting this answer, because it answers the question asked perfectly. I may end up going with the ragged right method of David Carlisle to avoid unnecssary packages. – Drew Mar 25 at 17:59

As there is no alignment here I probably wouldn't use breqn at all for this

enter image description here

\documentclass{amsart}
%\usepackage{breqn}

\newcommand{\longformula}{
1 + \Bigl(-\frac{1}{6} r^{3} + \frac{1}{6} r\Bigr)z^{2} +
\Bigl(\frac{17}{40} r^{5} - \frac{5}{8} r^{3} + \frac{1}{5}
r\Bigr)z^{3} + \Bigl(-\frac{631}{630} r^{7} + \frac{1}{72} r^{6} +
\frac{88}{45} r^{5} - \frac{1}{36} r^{4} - \frac{209}{180} r^{3} +
\frac{1}{72} r^{2} + \frac{29}{140} r\Bigr)z^{4} +
\Bigl(\frac{171215}{72576} r^{9} - \frac{17}{240} r^{8} -
\frac{69619}{12096} r^{7} + \frac{7}{40} r^{6} + \frac{16979}{3456}
r^{5} - \frac{11}{80} r^{4} - \frac{31259}{18144} r^{3} + \frac{1}{30}
r^{2} + \frac{13}{63} r\Bigr)z^{5} + \Bigl(-\frac{18684667}{3326400}
r^{11} + \frac{155581}{604800} r^{10} + \frac{597209}{36288} r^{9} -
\frac{1699}{2240} r^{8} - \frac{5513891}{302400} r^{7} +
\frac{23033}{28800} r^{6} + \frac{114685}{12096} r^{5} -
\frac{2669}{7560} r^{4} - \frac{519509}{226800} r^{3} + \frac{229}{4200}
r^{2} + \frac{281}{1386} r\Bigr)z^{6} +
\Bigl(\frac{401297449}{29652480} r^{13} - \frac{8914439}{10886400}
r^{12} - \frac{528153667}{11404800} r^{11} + \frac{30585833}{10886400}
r^{10} + \frac{4352347}{69120} r^{9} - \frac{13405099}{3628800} r^{8} -
\frac{44899771}{1036800} r^{7} + \frac{25156259}{10886400} r^{6} +
\frac{817639}{51840} r^{5} - \frac{1859441}{2721600} r^{4} -
\frac{339287}{118800} r^{3} + \frac{1433}{18900} r^{2} + \frac{85}{429}
r\Bigr)z^{7} + \Bigl(-\frac{448937586017}{13621608000} r^{15} +
\frac{545510843}{223534080} r^{14} + \frac{200873307991}{1556755200}
r^{13} - \frac{4578488741}{479001600} r^{12} -
\frac{41467078967}{199584000} r^{11} + \frac{653808103}{43545600} r^{10}
+ \frac{13531857077}{76204800} r^{9} - \frac{1224530857}{101606400}
r^{8} - \frac{4709184889}{54432000} r^{7} + \frac{56484901}{10886400}
r^{6} + \frac{119034073}{4989600} r^{5} - \frac{67641247}{59875200}
r^{4} - \frac{7752863023}{2270268000} r^{3} + \frac{1123657}{11642400}
r^{2} + \frac{9949}{51480} r\Bigr)z^{8} +
\Bigl(\frac{1067238963813721}{13173608448000} r^{17} -
\frac{4580572146421}{653837184000} r^{16} -
\frac{1868424788136953}{5230697472000} r^{15} +
\frac{1008805230793}{32691859200} r^{14} +
\frac{992904065416223}{1494484992000} r^{13} -
\frac{101113443793}{1796256000} r^{12} -
\frac{272962348105847}{402361344000} r^{11} +
\frac{25120947101}{457228800} r^{10} +
\frac{60592820342221}{146313216000} r^{9} -
\frac{141153688681}{4572288000} r^{8} -
\frac{4423647350867}{28740096000} r^{7} + \frac{7144205161}{718502400}
r^{6} + \frac{44170826140139}{1307674368000} r^{5} -
\frac{15354074077}{9081072000} r^{4} - \frac{36013858967}{9081072000}
r^{3} + \frac{48901}{420420} r^{2} + \frac{6871}{36465} r\Bigr)z^{9} +
\Bigl(-\frac{174424081161393493}{868893574348800} r^{19} +
\frac{740164886921567}{37661021798400} r^{18} +
\frac{525222462909510739}{533531142144000} r^{17} -
\frac{1509433069953143}{15692092416000} r^{16} -
\frac{32583814614724447}{15692092416000} r^{15} +
\frac{250692752979619}{1255367393280} r^{14} +
\frac{16579532320075783}{6725182464000} r^{13} -
\frac{829530467198351}{3621252096000} r^{12} -
\frac{4367664389322431}{2414168064000} r^{11} +
\frac{13899331735211}{87787929600} r^{10} +
\frac{2045747884459907}{2414168064000} r^{9} -
\frac{40609260170929}{603542016000} r^{8} -
\frac{423655761620591}{1681295616000} r^{7} +
\frac{40245068798999}{2353813862400} r^{6} +
\frac{29792663200381}{653837184000} r^{5} -
\frac{96567618673}{40864824000} r^{4} - \frac{115983959747}{25729704000}
r^{3} + \frac{6135329}{45405360} r^{2} + \frac{84883}{461890}
r\Bigr)z^{10} 
+ O(z^{11})
}

\begin{document}
Or simply

\begin{raggedright}\baselineskip2.5\baselineskip

$\displaystyle
A(z) = \longformula
$

\end{raggedright}


\end{document}
share|improve this answer
    
Why the $\displaystyle ... $ instead of \[...\]? – PTNobel Mar 24 at 0:41
1  
@PTNobel The best (read: least bad) way of displaying this monstrosity without having to manually determine where to break lines is to use TeX's line breaking algorithm, which means displaystyle with inline math; the raggedright environment suppresses justified lines to keep spacing consistent. – Jon Mar 24 at 3:17
    
not that it would really improve anything, but center would provide a bit of camouflage. – barbara beeton Mar 24 at 3:42
    
@PTNobel \[ is a single line display so would not work here. – David Carlisle Mar 24 at 7:55
    
@Jon makes sense. – PTNobel Mar 25 at 0:17

The equals sign can be hidden in a command to fool package breqn:

\mathchardef\EqualsSign=\mathcode`\=

This needs to be defined before package breqn is loaded, because the package redefines the math category code and makes the equals sign active in mathematical context.

Example:

\documentclass{amsart}
\mathchardef\EqualSign=\mathcode`\=
\usepackage{breqn}

\newcommand{\longformula}{...}

\begin{document}
  \begin{dmath*}
    A(z) \EqualSign \longformula
  \end{dmath*}
\end{document}
share|improve this answer

Put it in a box beforehand?? In particular,

\setbox0=\hbox{${}={}$}
\begin{dmath*}
A(z) \box0 \longformula
\end{dmath*}

Of course, this can alternately be automated as

\newsavebox\sveq
\savebox\sveq{$=$}
\def\EqualSign{\mathrel{\usebox{\sveq}}}

with \EqualSign being used as needed (if it is needed across smaller math styles, let me know, the fix is straightforward). Here is the MWE.

\documentclass{amsart}
\usepackage{breqn}

\newcommand{\longformula}{
1 + \left(-\frac{1}{6} r^{3} + \frac{1}{6} r\right)z^{2} +
\left(\frac{17}{40} r^{5} - \frac{5}{8} r^{3} + \frac{1}{5}
r\right)z^{3} + \left(-\frac{631}{630} r^{7} + \frac{1}{72} r^{6} +
\frac{88}{45} r^{5} - \frac{1}{36} r^{4} - \frac{209}{180} r^{3} +
\frac{1}{72} r^{2} + \frac{29}{140} r\right)z^{4} +
\left(\frac{171215}{72576} r^{9} - \frac{17}{240} r^{8} -
\frac{69619}{12096} r^{7} + \frac{7}{40} r^{6} + \frac{16979}{3456}
r^{5} - \frac{11}{80} r^{4} - \frac{31259}{18144} r^{3} + \frac{1}{30}
r^{2} + \frac{13}{63} r\right)z^{5} + \left(-\frac{18684667}{3326400}
r^{11} + \frac{155581}{604800} r^{10} + \frac{597209}{36288} r^{9} -
\frac{1699}{2240} r^{8} - \frac{5513891}{302400} r^{7} +
\frac{23033}{28800} r^{6} + \frac{114685}{12096} r^{5} -
\frac{2669}{7560} r^{4} - \frac{519509}{226800} r^{3} + \frac{229}{4200}
r^{2} + \frac{281}{1386} r\right)z^{6} +
\left(\frac{401297449}{29652480} r^{13} - \frac{8914439}{10886400}
r^{12} - \frac{528153667}{11404800} r^{11} + \frac{30585833}{10886400}
r^{10} + \frac{4352347}{69120} r^{9} - \frac{13405099}{3628800} r^{8} -
\frac{44899771}{1036800} r^{7} + \frac{25156259}{10886400} r^{6} +
\frac{817639}{51840} r^{5} - \frac{1859441}{2721600} r^{4} -
\frac{339287}{118800} r^{3} + \frac{1433}{18900} r^{2} + \frac{85}{429}
r\right)z^{7} + \left(-\frac{448937586017}{13621608000} r^{15} +
\frac{545510843}{223534080} r^{14} + \frac{200873307991}{1556755200}
r^{13} - \frac{4578488741}{479001600} r^{12} -
\frac{41467078967}{199584000} r^{11} + \frac{653808103}{43545600} r^{10}
+ \frac{13531857077}{76204800} r^{9} - \frac{1224530857}{101606400}
r^{8} - \frac{4709184889}{54432000} r^{7} + \frac{56484901}{10886400}
r^{6} + \frac{119034073}{4989600} r^{5} - \frac{67641247}{59875200}
r^{4} - \frac{7752863023}{2270268000} r^{3} + \frac{1123657}{11642400}
r^{2} + \frac{9949}{51480} r\right)z^{8} +
\left(\frac{1067238963813721}{13173608448000} r^{17} -
\frac{4580572146421}{653837184000} r^{16} -
\frac{1868424788136953}{5230697472000} r^{15} +
\frac{1008805230793}{32691859200} r^{14} +
\frac{992904065416223}{1494484992000} r^{13} -
\frac{101113443793}{1796256000} r^{12} -
\frac{272962348105847}{402361344000} r^{11} +
\frac{25120947101}{457228800} r^{10} +
\frac{60592820342221}{146313216000} r^{9} -
\frac{141153688681}{4572288000} r^{8} -
\frac{4423647350867}{28740096000} r^{7} + \frac{7144205161}{718502400}
r^{6} + \frac{44170826140139}{1307674368000} r^{5} -
\frac{15354074077}{9081072000} r^{4} - \frac{36013858967}{9081072000}
r^{3} + \frac{48901}{420420} r^{2} + \frac{6871}{36465} r\right)z^{9} +
\left(-\frac{174424081161393493}{868893574348800} r^{19} +
\frac{740164886921567}{37661021798400} r^{18} +
\frac{525222462909510739}{533531142144000} r^{17} -
\frac{1509433069953143}{15692092416000} r^{16} -
\frac{32583814614724447}{15692092416000} r^{15} +
\frac{250692752979619}{1255367393280} r^{14} +
\frac{16579532320075783}{6725182464000} r^{13} -
\frac{829530467198351}{3621252096000} r^{12} -
\frac{4367664389322431}{2414168064000} r^{11} +
\frac{13899331735211}{87787929600} r^{10} +
\frac{2045747884459907}{2414168064000} r^{9} -
\frac{40609260170929}{603542016000} r^{8} -
\frac{423655761620591}{1681295616000} r^{7} +
\frac{40245068798999}{2353813862400} r^{6} +
\frac{29792663200381}{653837184000} r^{5} -
\frac{96567618673}{40864824000} r^{4} - \frac{115983959747}{25729704000}
r^{3} + \frac{6135329}{45405360} r^{2} + \frac{84883}{461890}
r\right)z^{10} 
+ O(z^{11})
}

\begin{document}
looks good but I want the $\times$ to be an $=$:
\begin{dmath*}
A(z) \times \longformula
\end{dmath*}

looks bad to me:
\setbox0=\hbox{${}={}$}
\begin{dmath*}
A(z) \box0 \longformula
\end{dmath*}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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