0

In common words, the word wrap is done automatically. But in the equations, it doesn't work. Actually, I am making some presentation material using beamer in Latex.

Is there any way to make word wrap automatically? I hope the first line is left align, simultaneously, second line is right align

My code is like the following:

\begin{frame}[shrink=0, t]{The \textbf{\textit{DP}} Algorithm}
    \begin{center}
        \begin{minipage}{.9\textwidth}
            \begin{proof}

            \begin{enumerate}
            \setcounter{enumi}{4}
            \item Since $\pi^k=\left(\mu_k, \pi^{k+1}\right)$,
            \begin{align*}
                J_k^*(x_k) &= \min_{\left(\mu_k, \pi^{k+1}\right)} \underset{w_k, \cdots, w_{N-1}}{E}
                \left\{ g_k(x_k, \mu_k(x_k), w_k) + g_N(x_N) + \sum_{i=k+1}^{N-1} g_i(x_i, \mu_i(x_i), w_i)\right\}\\
                &= 123
            \end{align*}
            \end{enumerate}
            \end{proof}
        \end{minipage}
    \end{center}
\end{frame}

1212121

3
  • 1
    Equations do no automatic linebreaks
    – user31729
    Jun 24, 2016 at 4:31
  • Look at the breqn package
    – Aditya
    Jun 24, 2016 at 4:33
  • The esthetics of displayed equations do not automate well. For example, you would probably like to have the broken part align with the left brace. Also \left \right won't work over multiple lines. Jun 24, 2016 at 13:22

2 Answers 2

4

This is simply to show how to reformat the equation with as little effort as possible. Copy the line to be broken. Use \right. or \left. to balance an otherwise unmatched \left or \right. Use \hphantom to preserve spacing, and \vphantom to preserve the \left ... \right size.

Note, the additional \qquad is to compensate for the missing = and \{.

\documentclass{beamer}
\begin{document}
\begin{frame}[shrink=0, t]{The \textbf{\textit{DP}} Algorithm}
    \begin{center}
        \begin{minipage}{.9\textwidth}
            \begin{proof}

            \begin{enumerate}
            \setcounter{enumi}{4}
            \item Since $\pi^k=\left(\mu_k, \pi^{k+1}\right)$,
            \begin{align*}
                J_k^*(x_k) &= \min_{\left(\mu_k, \pi^{k+1}\right)} \underset{w_k, \cdots, w_{N-1}}{E}
                \left\{ g_k(x_k, \mu_k(x_k), w_k) + g_N(x_N) \vphantom{+ \sum_{i=k+1}^{N-1} g_i(x_i, \mu_i(x_i), w_i)}\right.\\
                &\qquad \hphantom{\min_{\left(\mu_k, \pi^{k+1}\right)} \underset{w_k, \cdots, w_{N-1}}{E}}
                \left. \vphantom{g_k(x_k, \mu_k(x_k), w_k) + g_N(x_N)} + \sum_{i=k+1}^{N-1} g_i(x_i, \mu_i(x_i), w_i)\right\}\\
                &= 123
            \end{align*}
            \end{enumerate}
            \end{proof}
        \end{minipage}
    \end{center}
\end{frame}
\end{document}

demo

0
4

You can use breqn package for this:

\documentclass{article}
\usepackage{amsthm,amsmath,breqn,lipsum}
\usepackage[showframe,margin=5cm]{geometry}
\begin{document}
\lipsum[1-2]
\begin{frame}[shrink=0, t]{The \textbf{\textit{DP}} Algorithm}
    \begin{center}
        \begin{minipage}{.9\textwidth}
            \begin{proof}

            \begin{enumerate}
            \setcounter{enumi}{4}
            \item Since $\pi^k=\left(\mu_k, \pi^{k+1}\right)$,
            \begin{dmath*}
                J_k^*(x_k) = \min_{\left(\mu_k, \pi^{k+1}\right)} \underset{w_k, \cdots, w_{N-1}}{E}
                \left\{ g_k(x_k, \mu_k(x_k), w_k) + g_N(x_N) + \sum_{i=k+1}^{N-1} g_i(x_i, \mu_i(x_i), w_i)\right\}\\
                = 123
            \end{dmath*}
            \end{enumerate}
            \end{proof}
        \end{minipage}
    \end{center}
\end{frame}
\lipsum[1-2]
\end{document}

demo

1
  • Thank you for answer. However, in mine, it does not work well. I made with h(v)phantom. I know your solution is not wrong, just my skill lacks in using your solution. T.T
    – Danny_Kim
    Jun 25, 2016 at 12:32

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.