Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the align package for multiple-row equations. Some rows the equations are just a bit longer than the textwidth (I'm using double column). I only want to reduce the fontsize of those particular rows, not the whole align environment. How do I do that?

share|improve this question
1  
Welcome to TeX.sx!. without a minimal working example (MWE) i'm just making a stab at a suggestion. you can use \text{...} in an align environment, separately for each segment (break points at start/end of line and any &), and within \text you can specify a size (\small, \Small, etc.) and then explicitly specify math with \displaystyle if appropriate. it's a hack, but you say you want just some rows, not the whole thing. –  barbara beeton Nov 29 '12 at 16:32

1 Answer 1

The mathtools package provides an \Aboxed macro that boxes an equation inside align environments (and family) across &.
The original code is:

\newcommand\Aboxed[1]{\let\bgroup{\romannumeral-`}\@Aboxed#1&&\ENDDNE}
\def\@Aboxed#1&#2&#3\ENDDNE{%
  \ifnum0=`{}\fi \setbox \z@
    \hbox{$\displaystyle#1{}\m@th$\kern\fboxsep \kern\fboxrule }%
    \edef\@tempa {\kern  \wd\z@ &\kern -\the\wd\z@ \fboxsep
        \the\fboxsep \fboxrule \the\fboxrule }\@tempa \boxed {#1#2}%
}

I’m going to adapt this by measuring the whole width of the equation and re-sizing the whole line to \linewidth. This’ll work with twocolumn, too, but showframe doesn’t show the inner column separator.

In the examples one can see that it works best when the one long line has on both sides of & the longest part of all lines.

The equal sign don’t align perfectly because the left part deos’nt end at the left side of = (and neither in the middle) but to the left from the additional space that is inserted before the relation sign (i.e. \thickmuskip) which will be scaled as well.

Code

\documentclass[
%   twocolumn,
]{article}
\usepackage{amsmath}
\usepackage{graphics}
\usepackage{pgf}
\makeatletter
\newdimen\width@one
\newdimen\width@two
\newdimen\width@onetwo
\newdimen\left@kern
\newcommand\Rboxed[1]{\let\bgroup{\romannumeral-`}\@Rboxed#1&&\ENDDNE}
\def\@Rboxed#1&#2&#3\ENDDNE{%
  \ifnum0=`{}\fi%
  \setbox0\hbox{$\displaystyle#1{}\m@th$}%
  \setbox1\hbox{$\displaystyle{}#2\m@th$}%
  \width@one=\wd0%
  \width@two=\wd1%
  \width@onetwo=\width@one%
  \advance\width@onetwo by \width@two%
  \pgfmathsetmacro{\width@factor}{\linewidth/\width@onetwo}%
  %%% Solution A
%  \pgfmathsetlength{\left@kern}{\width@factor*\width@one}%
%  \edef\@tempa{\kern\left@kern&\kern-\the\left@kern}\@tempa%
%  \scalebox{\width@factor}{$\displaystyle#1{}$}&\scalebox{\width@factor}{$\displaystyle{}#2$}%
%  \resizebox\linewidth!{$#1#2$}%
  %% Solution B
  \edef\@tempb{\noexpand\scalebox{\width@factor}{$\displaystyle#1{}$}&\noexpand\scalebox{\width@factor}{$\displaystyle{}#2$}}%
  \@tempb%
}
\makeatother
%\usepackage[showframe,pass]{geometry}
\usepackage{showframe}
\begin{document}
\begin{align*}
a^2 + b^2 & = c^2 \\
\Rboxed{long equation + very long equation + long equation + long equation + long equation & = a^2+b^2} \\
c^2 & = a^2 + b^2
\end{align*}

\begin{align*}
a^2 + b^2 & = c^2 \\
\Rboxed{long equation + very long equation + long equation + long equation & = a^2+b^2 + long equation} \\
c^2 & = a^2 + b^2
\end{align*}

\twocolumn
\begin{align*}
a^2 + b^2 & = c^2 \\
\Rboxed{long equation + long equation + long & = a^2+b^2} \\
c^2 & = a^2 + b^2
\end{align*}

\begin{align*}
a^2 + b^2 & = c^2 \\
\Rboxed{long equation + long equation + long & = a^2+b^2 + long equation} \\
c^2 & = a^2 + b^2
\end{align*}
\end{document}

Output

Output

share|improve this answer
    
Without an actual MWE or an use-case, this is an example of “This could work”. I guess that re-writing the formula or splitting on two lines is a valid (and maybe better) solution. –  Qrrbrbirlbel Nov 29 '12 at 17:38

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.