I am trying to put an equation in a block in one single line. But I could not able to do that. HOw to do this. This is what I tried.



\tikzstyle{block} = [rectangle, draw, fill=blue!20, 
text width=9em, text centered, rounded corners,minimum width=30em, minimum height=5em,node distance=5em]
\tikzstyle{block2} = [rectangle, draw, fill=yellow!20, 
text width=9em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']

\node [block] (gf) {\Large $
        EI_{zz}\,\frac{\partial ^4y\left(x,t\right)}{\partial x^4}+\rho A\frac{\partial ^2 y\left(x,t\right)}{\partial t^2}=-\sum_{j=1}^{m} k_{t,j}y(\zeta_{1,i})\delta(x-\zeta_{1,j})-\sum_{j=1}^{p}m_{j}\ddot{y}(\zeta_{2,j})\delta(x-\zeta_{2,j})+ \sum_{j=1}^{n}k_{r,s}y'(\zeta_{3,s})\delta(x-\zeta_{3,j})$ };   
  • 1
    Off topic: you should not use \tikzstyle anymore. – JouleV Mar 20 at 7:55
  • @JouleV should not is probably too strong. You can recommend (your personal taste that is shared with a lot of contributors on this site, I know, not me), but there is no reason to prohibit \tikzstyle. – Kpym Mar 20 at 8:50

If you require the equation to be set using \Large (for a 44% [!] linear increase in font size), the equation is just too long to fit on a single line.

The following solution uses a \multline* environment, and manages to place the equation on two rows. Observe that I changed text width=9em to text width=\textwidth. I also changed y' to \dot{y}; if you prefer the "prime" notation instead, you should probably change \ddot{y} to y''.

enter image description here

\usepackage{geometry} % set page parameters appropriately
\DeclareMathOperator{\E}{E} % expectations operator

%% "\tikzstyle{block} = [...]}" is deprecated
%\tikzstyle{block} = [rectangle, draw, fill=blue!20,
%    text width=\textwidth, text centered, rounded corners]

%% Per @marmot's comment, use "\tikzset{block/.style={...}}" instead:   
\tikzset{block/.style={rectangle, draw, fill=blue!20,   
     text width=\textwidth, text centered, rounded corners}}


\node [block] (gf) {\Large 
\E I_{zz}\,\frac{\partial^4 y(x,t)}{\partial x^4}
 +\rho A\,\frac{\partial^2 y(x,t)}{\partial t^2}
 =-\sum_{j=1}^{m} k_{t,j}y(\zeta_{1,i})\delta(x-\zeta_{1,j})\\
 + \sum_{j=1}^{n}k_{r,s}\dot{y}(\zeta_{3,s})\delta(x-\zeta_{3,j})%$
  • 1
    Please note that \tikzstyle is deprecated. Use \tikzset{block/.style={rectangle, draw, fill=blue!20, text width=\textwidth, text centered, rounded corners}} instead. line is not used in the MWE. – marmot Mar 20 at 13:46
  • @marmot - Many thanks for this; I've updated code accordingly. Out of curiosity: Would you know why the shaded block is currently slightly wider than \textwidth, even though the parameter text width=\textwidth is set? – Mico Mar 21 at 5:23

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.