1

This question already has an answer here:

I am trying to write an equation using this LaTeX code

\begin{equation}
\frac{n_d}{m_d}.\psi\left(x+1,y\right)+\frac{n_d}{m_d}.\psi\left(x-1,y\right)-2.\left(\frac{n_d}{m_d}+\frac{m_d}{n_d}\right).\psi\left(x,y\right)+\frac{m_d}{n_d}.\psi\left(x,y+1\right)+\frac{m_d}{n_d}.\psi\left(x,y-1\right)=m_d*n_d*\frac{q}{\epsilon}\left(n-p-C\right)
\end{equation}

but when I compile it I can only see a part of the equation in the generated pdf.

marked as duplicate by LaRiFaRi, egreg equations Jun 15 '15 at 7:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    Welcome to TeX.SX! This equation is just too long. You have to put it on two ore more lines. – LaRiFaRi Jun 15 '15 at 7:41
  • 2
    Also note that you can use \cdot for a multiplication dot. – Grimler Jun 15 '15 at 7:43
1

Your equation is too long to fit in one line. You could use the split environment, with the amsmath package, to break it in two or more lines:

\documentclass[10pt]{article}

\usepackage{amsmath}
\begin{document}

\begin{equation}
\begin{split}
\frac{n_d}{m_d}\cdot\psi\left(x+1,y\right)+\frac{n_d}{m_d}\cdot\psi\left(x-1,y\right)-2\cdot\left(\frac{n_d}{m_d}+\frac{m_d}{n_d}\right)\cdot\psi\left(x,y\right) \\
+\frac{m_d}{n_d}\cdot\psi\left(x,y+1\right)+\frac{m_d}{n_d}\cdot\psi\left(x,y-1\right)=m_dn_d\frac{q}{\epsilon}\left(n-p-C\right)
\end{split}
\end{equation}

\end{document}
  • As @Grimler pointed out, I replaced all the dots with \cdot. – MarcoG Jun 15 '15 at 7:50
  • @Grimler and Marco: The period is not wrong but just another style. You do not see that very often these days, but it still exists. Just for info. – LaRiFaRi Jun 15 '15 at 7:58
  • @LaRiFaRi Thanks for the info, I've never seen it. – MarcoG Jun 15 '15 at 8:02
  • Wiki says it is French or Bulgarian style. Maybe not as obsolescent as I thought. (but personally, I do not like it...) – LaRiFaRi Jun 15 '15 at 8:07
0

If an equation is too long to fit on a single line, you need to employ an alternative environment that allows for line breaks. The multline environment (provided by the amsmath package) would seem to be well suited for your equation.

I would also replace all instances of . and * (dots and stars) with simple thinspaces.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "multline"  environment

\begin{document}

\noindent
before: \texttt{equation} environment
\begin{equation}
\frac{n_d}{m_d}.\psi\left(x+1,y\right)+\frac{n_d}{m_d}. \psi\left(x-1,y\right)-2. \left(\frac{n_d}{m_d}+\frac{m_d}{n_d}\right). \psi\left(x,y\right)+\frac{m_d}{n_d}. \psi\left(x,y+1\right)+\frac{m_d}{n_d}. \psi\left(x,y-1\right)=m_d*n_d*\frac{q}{\epsilon}\left(n-p-C\right)
\end{equation}

\bigskip\noindent
after: \texttt{multline} environment, no ``.'' or ``$*$'', no \verb+\left+ or \verb+\right+ directives
\begin{multline}
\frac{n_d}{m_d}\, \psi(x+1,y)+\frac{n_d}{m_d}\, \psi(x-1,y)
-2\, \Bigl(\frac{n_d}{m_d}+\frac{m_d}{n_d}\Bigr)\, \psi(x,y)\\
+\frac{m_d}{n_d}\, \psi(x,y+1)+\frac{m_d}{n_d}\, \psi(x,y-1)
=m_d\, n_d\, \frac{q}{\epsilon}(n-p-C)
\end{multline}

\end{document} 
0

Here are two solutions. I used the geometry package, to have more sensible margins, and a split environment. In the second suggestion, I grouped terms in the l.h.s.In both I removed the useless dots, and all \left … \right pairs, replacing only the middle one with a pait \biggl … \biggr (the smaller size \Bigl … \Bigr might be OK too):

\documentclass{article}

\usepackage{mathtools}
\usepackage[showframe]{geometry}
\begin{document}

\begin{equation}
  \begin{split}
    \frac{n_d}{m_d} \psi(x+1,y) & +\frac{n_d}{m_d}.\psi(x-1,y)-2 \biggl(\frac{n_d}{m_d}+ \frac{m_d}{n_d}\biggr) \psi(x,yt) + \frac{m_d}{n_d}\psi(x,y+1)+\frac{m_d}{n_d}\psi(x,y-1) \\ & =m_d*n_d*\frac{q}{\epsilon}(n-p-C)
  \end{split}
\end{equation}


\begin{equation}
  \begin{split}
    \frac{n_d}{m_d}\bigl((\psi(x+1,y) + \psi(x-1,y)\bigr) & -2 \biggl(\frac{n_d}{m_d}+ \frac{m_d}{n_d}\biggr) \psi(x,yt) + \frac{m_d}{n_d}\bigl(\psi(x,y+1)+\psi(x,y-1)\bigr) \\ & =m_d*n_d*\frac{q}{\epsilon}(n-p-C)
  \end{split}
\end{equation}

\end{document} 

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.