1

This is my LaTeX code

I'm using these packages

\usepackage{physics}
\usepackage{amsmath} 
\usepackage{amssymb,latexsym,mathrsfs}

And the code is

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{physics}
\usepackage{amsmath} 

\usepackage{amssymb,latexsym,mathrsfs}

 \begin{document}
\begin{equation}
 \begin{aligned}
 \frac{1}{4}\sum\limits_{\substack{n = 1 \\ m = 1}} ^ {N_ { m }, N_{ m }} 
  \qty( \frac{\pi^{2}n^{ 2 }}{s _ { f } ^ { 2 } } + \frac{\pi ^ { 2 } m ^2} 
  { L ^ { 2 } } - \tilde { E } )  \underbrace {\int\limits_0^L \qty( \cos 
 \frac { \pi \qty( m ^ { \prime } - m ) x }{ L } - \cos \frac{\pi\qty( m ^ { 
\prime } + m ) z}{ L }) V(s,z) \dd{z} }_{I_1} \, \times \\
\underbrace {\int\limits_0^{s_f} \qty(\cos \f{\pi(n^\prime -n)s}{s_f} - \cos 
\frac{ \pi \qty( n^\prime + n ) s } { s _ { f } }) \dd{s}}_{I^\prime_1} 
\cdot  C_{n,m}  + \frac { 1 } { 4 } \sum\limits_{\substack{ n =1 \\ m = 1 }} 
^ { N _ { n }, N _ { m } } \int\limits _ { 0 } ^ { s _ { f } } \qty(  \cos 
\frac { \pi \left( n ^ { \prime } - n \right) s } { s _ { f } } - \cos \frac 
{ \pi \left( n ^ { \prime } + n \right) s } { s _ { f } } )\dd{s} \times \\
\int _ { 0 } ^ { L } \left[ \cos \frac { \pi \left( m ^ { \prime } - m 
\right) x } { L } - \cos \frac { \pi \left( m ^ { \prime } + m \right) z } { 
 L }  \right] V (s,z) \dd{z}\cdot C_{n,m}=0
 \end{aligned}
 \end{equation}
 \end{document}

and I get this

enter image description here

I want that my equation doesn't break in the margins.

Thanks a lot.

  • What is \qty? Please post a full compilable code. – Bernard Nov 3 '18 at 23:52
  • It's the same \left(..... \right), but with a \usepackage{physics} – PCat27 Nov 3 '18 at 23:54
  • 1
    What is \f? Your code does not compile. – Sigur Nov 3 '18 at 23:55
  • 2
    don't make it hard for people to help you, please make the example complete from \documentclass to \end{document} in particular you ask that it fits the margins without saying what size your page is.. – David Carlisle Nov 3 '18 at 23:56
  • 2
    why do you have \limits everywhere and why ^{\prime} instead of ' ? – David Carlisle Nov 3 '18 at 23:57
4

Well, given that you introduce the two abbreviations, I suspect that you will agree with me that this equation is a bit bulky. I'd hence like to argue that the readers, and even after some months you yourself, will appreciate if you disentangle things a bit, which at the same time solves the issue.

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{physics}
\usepackage{amsmath} 

\usepackage{amssymb,latexsym,mathrsfs}

\begin{document}
\begin{align}
 \frac{1}{4}&\sum\limits_{\substack{n = 1 \\ m = 1}} ^ {N_ { m }, N_{ m }} 
  \qty( \frac{\pi^{2}n^{ 2 }}{s _ { f } ^ { 2 } } + \frac{\pi ^ { 2 } m ^2} 
  { L ^ { 2 } } - \tilde { E } ) I_1
 \times I^\prime_1
 \cdot  C_{n,m}  \notag \\
+ \frac {1}{4}& \sum\limits_{\substack{ n =1 \\ m = 1 }} 
^ { N _ { n }, N _ { m } } \int\limits _ { 0 } ^ { s _ { f } } \qty(  \cos 
\frac { \pi \left( n ^ { \prime } - n \right) s } { s _ { f } } - \cos \frac 
{ \pi \left( n ^ { \prime } + n \right) s } { s _ { f } } )\dd{s} & \notag \\
 &\times \int _ { 0 } ^ { L } \left[ \cos \frac { \pi \left( m ^ { \prime } - m 
\right) x } { L } - \cos \frac { \pi \left( m ^ { \prime } + m \right) z } { 
 L }  \right] V (s,z) \dd{z}\cdot C_{n,m} =0\;,
\end{align}
where
\begin{subequations}
\begin{align}
  I_1&=\int\limits_0^L \qty( \cos 
 \frac { \pi \qty( m ^ { \prime } - m ) x }{ L } - \cos \frac{\pi\qty( m ^ { 
\prime } + m ) z}{ L }) V(s,z) \dd{z}\;, \\
 I^\prime_1&=\int\limits_0^{s_f} \qty(\cos f{\pi(n^\prime -n)s}{s_f} - \cos 
\frac{ \pi \qty( n^\prime + n ) s } { s _ { f } }) \dd{s}\;.
\end{align}
\end{subequations}

\end{document}

enter image description here

  • You're a good designer, it looks better, thank you very much. – PCat27 Nov 4 '18 at 0:50
1

I propose to use the medsize environment from nccmath, and alsp a variant with the multlined environment, instead of aligned. Note you don't have to load latexsym: its symbols are found in amssymb, and it's simpler to type ' rather than ^{\prime}. For the integral with limits, you simply can pass limits as an option to amsmath.

    \documentclass[intlimits]{article}
\usepackage[showframe]{geometry}
\usepackage{physics}
\usepackage{mathtools, nccmath}
\usepackage{amssymb,mathrsfs}

    \begin{document}

\begin{equation}
\begin{medsize}
     \begin{aligned}
 \frac{1}{4}\sum_{\substack{n = 1 \\ m = 1}}^{N_{m}, N _{m}}
 \qty(\frac{\pi^{2} n^{2}}{ s_{f}^{2}} + \frac{\pi^{2} m^{2} } {L^{2}} - \tilde{ E })
 \underbrace {\int_0^L \qty( \cos \frac { \pi \qty( m' - m )
 x }{ L } - \cos \frac{\pi\qty( m' + m ) z}{ L }) V(s,z) \dd{z} }_{I_1} \, \times \\
  \underbrace {\int_0^{s_{\mkern-2mu\mathrlap{ f}}} \qty(\cos \frac{\pi(n' -n)s}{s_f} - \cos \frac{\pi \qty( n' + n ) s } { s_{ f }}) \dd{s}}_{I'_1}{} \cdot C_{n,m} + \frac { 1 } { 4 } \sum\limits_{\substack{ n =1 \\ m = 1 }} ^ { N _ { n }, N _ { m } } \int _ {0}^ {s_{\mkern-2mu\mathrlap{ f}}} \qty( \cos \frac {\pi \left( n' - n \right) s} {s_{f}} - \cos \frac{\pi \left( n' + n \right)s} {s _{f}})\dd{s} \times \\
\int_{0}^{L} \left[\cos \frac{\pi \left(m' - m \right) x } {L} - \cos \frac{\pi \left( m' + m \right)z} {L} \right] V (s,z) \dd{z}\cdot C_{n,m}=0
\end{aligned}
\end{medsize}
\end{equation}
\bigskip

\begin{equation}
\begin{medsize}
\begin{multlined}
 \frac{1}{4}\sum_{\substack{n = 1 \\ m = 1}}^{N_{m}, N _{m}}
 \qty(\frac{\pi^{2} n^{2}}{ s_{f}^{2}} + \frac{\pi^{2} m^{2} } {L^{2}} - \tilde{ E })
 \underbrace {\int_0^L \qty( \cos \frac { \pi \qty( m' - m )
 x }{ L } - \cos \frac{\pi\qty( m' + m ) z}{ L }) V(s,z) \dd{z} }_{I_1} \, \times \\
  \underbrace {\int_0^{s_{\mkern-2mu\mathrlap{ f}}} \qty(\cos \frac{\pi(n' -n)s}{s_f} - \cos \frac{\pi \qty( n' + n ) s } { s_{ f }}) \dd{s}}_{I'_1}{} \cdot C_{n,m} + \frac { 1 } { 4 } \sum\limits_{\substack{ n =1 \\ m = 1 }} ^ { N _ { n }, N _ { m } } \int _ {0}^ {s_{\mkern-2mu\mathrlap{ f}}} \qty( \cos \frac {\pi \left( n' - n \right) s} {s_{f}} - \cos \frac{\pi \left( n' + n \right)s} {s _{f}})\dd{s} \times \\
\int_{0}^{L} \left[\cos \frac{\pi \left(m' - m \right) x } {L} - \cos \frac{\pi \left( m' + m \right)z} {L} \right] V (s,z) \dd{z}\cdot C_{n,m}=0
\end{multlined}
 \end{medsize}
\end{equation}

\end{document} 

enter image description here

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.