3

I am a LaTex beginner and I am writing my first formal document using it.
I have to write a quite long equation, and it goes out of page bounds for some reason as I show here:

enter image description here

Here you are the code I run:

\begin{align}
\begin{split}
f(x,y,z,w) = (x+y+z+\bar{w}) * (x+y+\bar{z}+\bar{w}) * (x+\bar{y}+z+w) * (x+\bar{y}+\bar{z}+w) * (x+\bar{y}+\bar{z}+\bar{w}) * (\bar{x}+y+z+w) * (\bar{x}+y+z+\bar{w}) * (\bar{x}+y+\bar{z}+w) * (\bar{x}+\bar{y}+z+\bar{w}) * (\bar{x}+\bar{y}+\bar{z}+w) 
\end{split}
\end{align}

How can I solve this? Thank you for your patience and consideration.

  • Adding line breaks somewhere (\\)? – Fran Apr 11 at 10:18
  • @Fran Can Is there a command to make it automatic? So that if I change something in the equation it will adjust automatically. – Eminent Emperor Penguin Apr 11 at 10:22
  • 2
    split allows splitting across lines, but does not do it: the author has to decide where to set the line breaks. – egreg Apr 11 at 10:22
3

One possible solution....to split it....with edit by comment of the user.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{align}
\begin{split}
f(x,y,z,w) & = (x+y+z+\bar{w})\cdot (x+y+\bar{z}+\bar{w})\cdot (x+\bar{y}+z+w) \\
&\cdot  (x+\bar{y}+\bar{z}+w) \cdot (x+\bar{y}+\bar{z}+\bar{w}) \cdot (\bar{x}+y+z+w) \\
&\cdot (\bar{x}+y+z+\bar{w}) \cdot (\bar{x}+y+\bar{z}+w)\\
& \cdot (\bar{x}+\bar{y}+z+\bar{w}) \cdot  (\bar{x}+\bar{y}+\bar{z}+w)
\end{split}
\end{align}
\end{document}
| improve this answer | |
  • Just a little problem: in the last line, there should be a \cdot instead of a = but this is what I am looking for, thank you! – Eminent Emperor Penguin Apr 11 at 10:29
  • 1
    @EminentEmperorPenguin I'm happy to help you..can you see, please, if is it good now? – Sebastiano Apr 11 at 10:32
  • 1
    All good now. Thank you. – Eminent Emperor Penguin Apr 11 at 10:41
  • 1
    Please, can you check green mark to egreg? It is the best answer than mine. Thank you very much. – Sebastiano Apr 11 at 12:19
  • @EminentEmperorPenguin There is yet, the green check mark...switch it to egreg. Thank you very much. After you choose any codes. – Sebastiano Apr 11 at 19:32
3

I can propose an autosplit environment, but it's much better to split the big thing by hand as in the last example.

The optional argument to autosplit is the fraction of the display width to fill. The default is 0.9 (that is, 90%).

\documentclass{article}
\usepackage{amsmath}

\newenvironment{autosplit}[2][0.9]
 {%
  \settowidth{\dimen0}{$#2{}$}%
  \begin{tabular}{@{}c@{}}
  $\displaystyle#2{}$%
  \begin{minipage}[t]{\dimexpr#1\displaywidth-\dimen0}
  %\raggedright
  $\displaystyle
 }
 {$\end{minipage}\end{tabular}}

\begin{document}

\begin{equation}
\begin{autosplit}{f(x,y,z,w) =}
  (x+y+z+\bar{w}) \* (x+y+\bar{z}+\bar{w}) \* (x+\bar{y}+z+w) \* 
  (x+\bar{y}+\bar{z}+w) \* (x+\bar{y}+\bar{z}+\bar{w}) \* (\bar{x}+y+z+w) \* 
  (\bar{x}+y+z+\bar{w}) \* (\bar{x}+y+\bar{z}+w) \* (\bar{x}+\bar{y}+z+\bar{w}) \* 
  (\bar{x}+\bar{y}+\bar{z}+w) 
\end{autosplit}
\end{equation}

\begin{equation}
\begin{autosplit}[0.8]{f(x,y,z,w) =}
  (x+y+z+\bar{w}) \* (x+y+\bar{z}+\bar{w}) \* (x+\bar{y}+z+w) \* 
  (x+\bar{y}+\bar{z}+w) \* (x+\bar{y}+\bar{z}+\bar{w}) \* (\bar{x}+y+z+w) \* 
  (\bar{x}+y+z+\bar{w}) \* (\bar{x}+y+\bar{z}+w) \* (\bar{x}+\bar{y}+z+\bar{w}) \* 
  (\bar{x}+\bar{y}+\bar{z}+w) 
\end{autosplit}
\end{equation}

\begin{equation}
\begin{split}
f(x,y,z,w)={}&
  (x+y+z+\bar{w}) (x+y+\bar{z}+\bar{w}) (x+\bar{y}+z+w) \\
{}\cdot{}&
  (x+\bar{y}+\bar{z}+w) (x+\bar{y}+\bar{z}+\bar{w}) (\bar{x}+y+z+w) \\
{}\cdot{}&
  (\bar{x}+y+z+\bar{w}) (\bar{x}+y+\bar{z}+w) (\bar{x}+\bar{y}+z+\bar{w}) \\
{}\cdot{}&
  (\bar{x}+\bar{y}+\bar{z}+w) 
\end{split}
\end{equation}

\end{document}

enter image description here

| improve this answer | |
  • autosplit is good but as I tried, I found the standard method clearer. Thank you anyway! – Eminent Emperor Penguin Apr 11 at 12:43
  • @EminentEmperorPenguin I mentioned it just to show the limitations with having TeX doing the breaks itself. – egreg Apr 11 at 12:59

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.