3

Sometimes I have huge math equations which are longer than the linewidth, so I am wondering if here is some macro to zoom in the equation to avoid it being rendered outside the line? (I am using \twocolumn style). The overlong equations are damn ugly.

Like the code

\documentclass{article}
\begin{document}
\twocolumn
\setlength{\columnseprule}{0.4pt}
\[\frac{veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongword}{a}\]
\newpage
\[\frac{veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongword}{a}\]
\end{document}

enter image description here

The two long fraction will overlap each other. I want to have the overlong equations to zoom in to adapt the linewidth.

  • 4
    Try with \usepackage{graphicx} and then \[ \resizebox{.9\columnwidth}{!}{$\displaystyle \frac{<num>}{<denom>}$} \]. It will still look ugly though. It may be better to restructure your \frac by using other symbols instead, and define the symbols to mean more complex things within the text (say). – Werner Mar 8 '17 at 3:46
4

If the main issue is with very long numerator (or denominator) terms in a \frac expression, try using the \splitfrac macro that's provided by the mathtools package. Note: \splitfrac directives may be nested, if needed.

This method doesn't provide automatic line breaks, as you seem to want to have. But then only the writer -- certainly not the software -- is in a position to judge where having line breaks would be OK. And, for sure, splitting a long numerator deliberately produces far better typographic results than does shoehorning the entire equation into the with of the column via a \resizebox directive -- see below.

enter image description here

\documentclass[twocolumn]{article}
\setlength{\columnseprule}{0.4pt}
\usepackage{graphicx}  % for "\resizebox" macro
\usepackage{mathtools} % for "\splitfrac" macro
\begin{document}
\[
\frac{\splitfrac{veryveryveryveryveryveryveryvery}{veryveryveryveryveryveryverylongword}}{a}
\]
vs.
\[
\resizebox{0.95\columnwidth}{!}{$\displaystyle
\frac{veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongword}{a}$}
\]
\end{document}
| improve this answer | |
  • Thank you. resizebox fits me better. But here's another problem that 'resizebox' will enlarge the short equations. Is here any way to take the overlong equations out? (or the inline equations that extrude the boundary) – Sui Chen Mar 8 '17 at 10:13
  • @SuiChen you can specify max width with resizebox but look at the adjustbox package which has a nicer interface for such things – David Carlisle Mar 8 '17 at 13:15
  • @SuiChen - Just to follow up on David's comment: To implement his suggestion, you'd load the adjustbox package in the preamble and type something like \[ \adjustbox{max width=0.95\columnwidth}{$\displaystyle\frac{<numerator>}{<denominator>}$} \] in the body of the document. – Mico Mar 8 '17 at 15:28

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.