5

I write article at first, but I also need pdf in beamer version. But I found for those long equations appears fine in "article" will exceed the page width in "beamer" mode. So is there a method to avoid this automatically?

A MWE is as follows:

\documentclass[12pt]{beamer} \usepackage{amsmath,amssymb,amsthm}

\begin{document}
  \begin{equation}\label{}
    \int_C {{\mathbf{F}}\left( {x,y} \right) \cdot d{\mathbf{r}}}  = \int_C {\left( {f\left( x \right){\mathbf{i}} + g\left( y \right){\mathbf{j}}} \right) \cdot \left( {dx{\mathbf{i}} + dy{\mathbf{j}}} \right)}  = \int_C {f\left( x \right)dx}  + \int_C {g\left( y \right)dy}
  \end{equation}
\end{document} 

gives

enter image description here

After change documentclass from article to beamer

\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}

\begin{document}
  \begin{equation}\label{}
    \int_C {{\mathbf{F}}\left( {x,y} \right) \cdot d{\mathbf{r}}}  = \int_C {\left( {f\left( x \right){\mathbf{i}} + g\left( y \right){\mathbf{j}}} \right) \cdot \left( {dx{\mathbf{i}} + dy{\mathbf{j}}} \right)}  = \int_C {f\left( x \right)dx}  + \int_C {g\left( y \right)dy}
  \end{equation}
\end{document} 

gives

enter image description here

13
  • 1
    Welcome to TeX SX! Could we have a minimal working example, so we can test?
    – Bernard
    Apr 22, 2015 at 12:45
  • 1
    Why do you ask why? The alignment has manually broken alignment designed for the page size and fonts in article, and you have changed the page size and fonts so having to adjust the manually inserted \\ line breaks should be the expected outcome. Apr 22, 2015 at 12:50
  • What font are you using, by the way? The spacing around some of the letters and symbols seems quite unusual, to put it politely.
    – Mico
    Apr 22, 2015 at 13:05
  • @Mico I use "unicode-math" and XITS math fonts
    – user15964
    Apr 22, 2015 at 13:06
  • @DavidCarlisle Oh, so equation environment can't handle long equations automatically?
    – user15964
    Apr 22, 2015 at 13:07

2 Answers 2

9

I suggest you do the following:

  • Insert a line-break instruction (\\) and one additional alignment point indicator (&). That way, TeX can tell where to break the lines and on which points to align the rows.

With this change in place, one gets:

enter image description here

I would like to urge you to consider making a few more changes:

  • Use a \notag instruction at the end of the first row to suppress the equation number on that line.

  • Delete all \left and \right directives. Doing so will markedly improve the spacing around the parentheses. Plus, they don't "do" anything anyway, in terms of changing the size of the parentheses: the material they enclose isn't tall or deep, and thus the size of the parentheses remains at the smallest possible value. If you really need to change the sizes of the parentheses, use \bigl( and \bigr), as is done in one case in the code below.

  • Get rid of all curly braces, with the exception of those associated with the \mathbf directives. In TeX's math mode, having all these curly braces running around is not innocuous: Surrounding some material with curly braces converts its type to "math-ordinary", obliterating any chance TeX may have to fine-tune the spacing around items of type "math-open", "math-close", etc.

  • Replace the \cdot directives with \, (thinspace), and insert \, before the "differential operators" -- d\mathbf{r}, dx, and dj.

enter image description here

\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}
\begin{document}

\begin{frame}
  \begin{align}
    \int_C \mathbf{F}( x,y ) \, d\mathbf{r}  
    &= \int_C \bigl( f( x )\,\mathbf{i} + g( y )\,\mathbf{j} \bigr) \, 
        ( dx\,\mathbf{i} + dy\,\mathbf{j} )  \notag\\
    &= \int_C f( x )\,dx  + \int_C g( y )\,dy 
        \label{eq:complex_int}
  \end{align}
\end{frame}

\end{document}
4
  • @DavidCarlisle Mico, Thank you so much for your suggestions. But you probably misunderstood my questions. I need both of "article" and "beamer“ version of pdf. But Those long equations are just fine in "article", they are just too long for "beamer". But if I I add "\\" manually to each equation in "beamer", that will be a lot of work. What I need is some additional setting in the preamble when I switch from "article" to "beamer" to make sure that all equation behaves normal automatically.
    – user15964
    Apr 23, 2015 at 11:24
  • 1
    @user15964 as I said in the original comment equation breaking is manual you have chosen the breaks so you need to choose breaks that are suitable for both contexts or to encode the equation twice and have a test so that the correct version is included into each context. Your question is the same as saying you have \rule{6cm}{1cm} and it fits in a 7cm wide document but not in a 5cm one, the system can not do anything about that automatically. Apr 23, 2015 at 11:31
  • @user15964 - Just because the single-line form of the equation happens to fit inside the text block when you use the article document class does not mean that it's typographically sound to do so (when using the article class). Do try to put effective and appealing presentation of your results ahead of your convenience as a writer. To sum up: do try to learn to use align-type environments effectively and correctly.
    – Mico
    Apr 23, 2015 at 11:33
  • @DavidCarlisle OK, I understand
    – user15964
    Apr 23, 2015 at 13:18
1

The font size in article and beamer are not the same. If you realy like to have one line equation in bemare, you need to use smaller fonts, for example scriptsize:

\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}

\begin{document}
My important one-line equation is:
  \begin{equation}\label{eq:1}\scriptsize
    \int_C {{\mathbf{F}}\left( {x,y} \right) \cdot d{\mathbf{r}}}  = \int_C {\left( {f\left( x \right){\mathbf{i}} + g\left( y \right){\mathbf{j}}} \right) \cdot \left( {dx{\mathbf{i}} + dy{\mathbf{j}}} \right)}  = \int_C {f\left( x \right)dx}  + \int_C {g\left( y \right)dy}
  \end{equation}
From (\ref{eq:q}) follows: \dots
\end{document}

enter image description here

To my opinion, the result is not so nice as at @Mico answer.

1
  • Thank you for your answer, \scriptsize is a good method.
    – user15964
    Dec 5, 2015 at 1:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .