Math & ScienceWriting one formula exactly below another formula

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
coolvenki
Posts: 5
Joined: Fri Feb 21, 2014 9:37 pm

Writing one formula exactly below another formula

Post by coolvenki »

Hi,
I am using Texmaker on windows 8 and I have TexLive 2013 installed. I am preparing an assignment in which I have to write some formulas and then substitute them with suitable number and then arrive on final value of the unknown. Unfortunately, all the formulas are centered. Hence if I want to show Hmax text one below another exactly, it does not do it. Can someone help? Given below is the relevant part of the code. Thanks.
$$H_{max}= 2^{0.5} \times H_s \times (ln [N])^{0.5}/2$$
$$H_{max}= 2^{0.5} \times 16 \times (ln [750])^{0.5}/2$$
$$H_{max}= 29.11 m$$
$$T=4.43\times H^{0.5}$$
$$T=4.43\times 29.11^{0.5}$$
$$T=23.90s$$
$$L=1.56\times T^2$$
$$L=1.56\times 23.90^2$$
$$L=891.18 m$$
$$k=\frac{2 \pi}{L}$$
$$k=\frac{2\pi}{891.18}$$
$$k=7.05 \times 10^{-3}$$
$$\frac{F_{max}}{(p \times g \times D^3)}=2 \times (\pi/8) \times \frac{H/L}{D/L} \times tanh (k.h)$$
$$F_{max}= (1025 \times 9.81 \times 95^3)\times (\pi/8)\times (29.11/95)\times tanh (70\times 7.05\times 10^{-3})$$
$$F_{max}=948.153 MN$$
$$M_{max}=2.\frac{p.g.R^2.H.L}{4\pi}. [kh.tanh(k.h)+ sech(k.h)-1]$$
$$M_{max}=10771.71 MNm$$
$$Check \frac{F_{max}}{V}= \frac{948.153}{4625}= 0.21<0.4$$

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Writing one formula exactly below another formula

Post by Johannes_B »

Do not use $$ math $$ to write down math. Use the appropriate amsmath environments. Have a look at the following code. I just did some Search and replace along the lines, please notcie differences to your code, tough not everything is changed correctly. Not the subscript, the operators (ln, also tanh is an operator). Plaese also have a look at package siunitx.

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\usepackage{siunitx}
\begin{document}
\begin{align}
H_{\max}&= 2^{0.5} \times H_s \times (\ln [N])^{0.5}/2\\
H_{\max}&= 2^{0.5} \times 16 \times (\ln [750])^{0.5}/2\\
H_{\max}&= \SI{29.11}{\meter} \\
T&=4.43\times H^{0.5}\\
T&=4.43\times 29.11^{0.5}\\
T&=23.90s\\
L&=1.56\times T^2\\
L&=1.56\times 23.90^2\\
L&=891.18 m\\
k&=\frac{2 \pi}{L}\\
k&=\frac{2\pi}{891.18}\\
k&=7.05 \times 10^{-3}\\
\frac{F_{\max}}{(p \times g \times D^3)}&=2 \times (\pi/8) \times\\
\frac{H/L}{D/L} \times tanh (k.h)\\
F_{\max}&= (1025 \times 9.81 \times 95^3)\times (\pi/8)\times\\
(29.11/95)\times tanh (70\times 7.05\times 10^{-3})\\
F_{\max}&=948.153 MN\\
M_{\max}&=2.\frac{p.g.R^2.H.L}{4\pi}. [kh.tanh(k.h)+\\
sech(k.h)-1]\\
M_{\max}&=\SI{10771.71}{\mega\newton\meter} \\
\text{Check} \frac{F_{\max}}{V}&= \frac{948.153}{4625}&= 0.21<0.4\\
\end{align}
\end{document}
Please read some basic introduction to mathematics and LaTeX: Mathmode.
If you have further questions, please prepare a minimal working example.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
coolvenki
Posts: 5
Joined: Fri Feb 21, 2014 9:37 pm

Writing one formula exactly below another formula

Post by coolvenki »

Thanks for reply firstly.
Given below is the complete code after modifications. But after running it, I see Badbox-Line 64 overfull\hbox(66.12054 pt too wide) in para at line64--64. Is there any problem given that I am going to add 1 more of formulas?
\documentclass[12pt,a4paper,fleqn]{article}
\usepackage{mathtools}
\usepackage{siunitx}
\begin{document}

\begin{titlepage}
\centering
\vspace*{10\baselineskip}
\large
\bfseries
\uppercase{Assignment 2}
\normalfont
\small
\vfill
by
\vfill
Venkatesh M \underline{Deshpande} \\
\vfill
Graduate Program in Civil and Environmental Engineering
\vfill
An assignment submitted in partial fulfilment \\
of the requirement for the course \\
CEE 9880-- Offshore Geotechnical Engineering \\
\vfill
The University of XXX\\
XXXX,Canada\\
\end{titlepage}
\begin{center}
\underline {Answer 1 Part A}\\
\end{center}
\renewcommand{\baselinestretch}{1.5}\normalsize
Significant wave height is calculated as the average of the highest one--third of all of the wave heights during the 20-minute sampling period. NDBC reported wave measurements are not directly measured by sensors on board the buoys. Instead, the accelerometers or inclinometers on board the buoys measure the heave acceleration or the vertical displacement of the buoy hull during the wave acquisition time. A Fast Fourier Transform (FFT) is applied to the data by the processor on board the buoy to transform the data from the temporal domain into the frequency domain. Note that the raw acceleration or displacement measurements are not transmitted shore-side. Response amplitude operator (RAO) processing is then performed on the transformed data to account for both hull and electronic noise. It is from this transformation that non-directional spectral wave measurements (i.e., wave energies with their associated frequencies) are derived. Along with the spectral energies, measurements such as significant wave height (WVHT), average wave period (AVGPD), and dominant period (DOMPD) are also derived from the transformation. $$AVHT=4\times\sqrt{m_{0}}$$ AVHT is significant wave height in meters\\
$m_{0}$ is the variance of the wave displacement time series acquired during the wave acquisition period
\begin{center}
\underline{Answer 1 Part C}
\end{center}
The dominant wave direction for each sea state is the direction with the most wave energy in a directional spectrum,$S(f,\alpha)$, where NDBC's direction convention is used. NDBC typically calculates $S(f,\alpha)$ at 5$^\circ$ intervals to estimate peak,or dominant, wave direction.
\pagebreak
\begin{center}
\underline{Answer 1 Part D}
\end{center}
\begin{align*}
H_{\max}&= 2^{0.5} \times H_s \times (\ln [N])^{0.5}/2\\
H_{\max}&= 2^{0.5} \times 16 \times (\ln [750])^{0.5}/2\\
H_{\max}&= \SI{29.11}{\meter} \\
T&=4.43\times H^{0.5}\\
T&=4.43\times 29.11^{0.5}\\
T&=23.90s\\
L&=1.56\times T^2\\
L&=1.56\times 23.90^2\\
L&=891.18 m\\
k&=\frac{2 \pi}{L}\\
k&=\frac{2\pi}{891.18}\\
k&=7.05 \times 10^{-3}\\
\frac{F_{\max}}{(p \times g \times D^3)}&=2 \times (\pi/8) \times
\frac{H/L}{D/L} \times tanh (k.h)\\
F_{\max}&= (1025 \times 9.81 \times 95^3)\times (\pi/8)\times
(29.11/95)\times tanh (70\times 7.05\times 10^{-3})\\
F_{\max}&=948.153 MN\\
M_{\max}&=2.\frac{p.g.R^2.H.L}{4\pi}. [kh.tanh(k.h)+
sech(k.h)-1]\\
M_{\max}&=\SI{10771.71}{\mega\newton\meter} \\
\text{Check} \frac{F_{\max}}{V}&= \frac{948.153}{4625}= 0.21<0.4\\
\end{align*}
\newpage
\begin{center}
\underline{Answer 2 Part B}
\end{center}

\end{document}
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Writing one formula exactly below another formula

Post by hugovdberg »

Please enclose large portions of code between code tags instead of latex, that way code highlighting is applied. Also please post only the relevant code, removing the titlepage does not remove the error, only the reported line number. Removing some more code from the align environment until you are left with the line causing the problem is usually the best way to learn for yourself what the exact cause is.

On topic, Overfull hbox means latex encountered a line that could not fit within the textblock, and overflows into the margins or even off the page. In this case it is the line calculating Fmax. You could either do that calculation in two separate steps, or break it up and add some extra indentation as I did in the code below.

Some extra tips, just as \ln is a math operator which is typeset in straight roman letters, \tanh and \sech are also known to latex.
Furthermore I see a lot of dots in your equations, I guess they are meant as multiplying dots, which are usually typeset vertically centered, this is done by means of the \cdot.
Also, sometimes looks nicer when the brackets around parts of an equation are scaled to the contents, especially with nested brackets. This is achieved with the \left and \right commands.

Code: Select all

\documentclass[12pt,a4paper,fleqn]{article}
\usepackage{mathtools}
\usepackage{siunitx}
\begin{document}

\begin{align*}
H_{\max}&= 2^{0.5} \times H_s \times (\ln [N])^{0.5}/2\\
H_{\max}&= 2^{0.5} \times 16 \times (\ln [750])^{0.5}/2\\
H_{\max}&= \SI{29.11}{\meter} \\
T&=4.43\times H^{0.5}\\
T&=4.43\times 29.11^{0.5}\\
T&=23.90s\\
L&=1.56\times T^2\\
L&=1.56\times 23.90^2\\
L&=891.18 m\\
k&=\frac{2 \pi}{L}\\
k&=\frac{2\pi}{891.18}\\
k&=7.05 \times 10^{-3}\\
\frac{F_{\max}}{(p \times g \times D^3)}&=2 \times (\pi/8) \times
\frac{H/L}{D/L} \times tanh (k.h)\\
F_{\max}&= (1025 \times 9.81 \times 95^3)\times (\pi/8)\times
(29.11/95)\times\\
	&\hspace{12em} \tanh (70\times 7.05\times 10^{-3})\\
F_{\max}&=948.153 MN\\
M_{\max}&=2.\frac{p.g.R^2.H.L}{4\pi}. [kh.tanh(k.h)+
sech(k.h)-1]\\
M_{\max}&=\SI{10771.71}{\mega\newton\meter} \\
\text{Check} \frac{F_{\max}}{V}&= \frac{948.153}{4625}= 0.21<0.4\\
\end{align*}

\end{document}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
coolvenki
Posts: 5
Joined: Fri Feb 21, 2014 9:37 pm

Writing one formula exactly below another formula

Post by coolvenki »

I have incorporated the suggestions you have told. But still there are some problems which I am facing.
1. When I am inserting any text, then all the formulas move towards right side and hence they are not in line with formula written on previous page (whose code I have given above).
2. How do I extend the sq rt over whole of the expression R^2-r^2 rather than just at the beginning?
p_0 &= 20.2 \times 5\\
&= \SI{101}{\kilo \Pa}\\
q_d &= \left(\frac{250 \times 5.14 \times 1.19 \times 0.822}{1.25}+ 101 \right)\\
&= \SI{1104.03}{\kilo \Pa}\\
\text{Check Sliding Resistance}\\
H<A_{eff} \cdot c_{ud}\\
A_{eff} \cdot c_{ud} &= \left(6492 \times \frac{250}{1.25} \right)\\
&= \SI{1298.26}{\mega \newton}\\
948.15 &<1298.26
\end{align*}
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Writing one formula exactly below another formula

Post by hugovdberg »

To answer your second question first: \sqrt can take an argument between brackets to denote the extent of the square root.

Regarding your first question, I think you mean by adding the \text{} command in the align environment. It is true your equations will shift to the right since you provided no alignment point (with an &). To insert text inside the align environment you should use either \intertext or \shortintertext, the latter producing less whitespace around the text. However, I don't think I understand your point about not being in line with the formula written on the previous page. Perhaps this is caused by the fact that equations within one align environment are aligned, but not necessarily to equations in other align environments, if this is really necessary you should use a single environment and \intertext commands.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Writing one formula exactly below another formula

Post by Johannes_B »

If you want face-to-the-problem help, you should make it easy to help. Personally, i don't like guessing, and i don't need to (nobody of us does), if you prepare a Minimal Working Example. That way, we all have the same basis.

Please click on Open in wirtelatex to see the output.

Code: Select all

\documentclass{article}
\begin{document}
hallo [
\end{document}
This is done using a

Code: Select all

-Block, not [latex] (which produces inline markup)!
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
coolvenki
Posts: 5
Joined: Fri Feb 21, 2014 9:37 pm

Re: Writing one formula exactly below another formula

Post by coolvenki »

Thank you pointing out areas where I can improve on submitting my queries. I accept these points. I have also learned something and improvised my code. I will submit a minimal working example or similar in coming days but not today since I have to submit the assignment tomorrow. I will try to work around whatever I have gained so far. However, without writing the code, I am briefly writing my problem down.
I have to write 2 to 3 pages of formulas. Formulas means write the eqn first, substitute and arrive at the value of unknown. For example,
K=a+b
K=2+3
K=5
Secondly, in between these eqns, I have to write some text. . That is when the eqn. starts moving right. I used \text, \intertext, \shortintertext If I use a single {align} command as pointed out above in a previous reply, then I am not able to use commands like \newpage which help in moving to new page and display a new answer on next page. And that is why I have used 3 align* in my code and \newpage or \begin{center} commands in between align*.
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Writing one formula exactly below another formula

Post by hugovdberg »

Take a look at this question at tex.se: http://tex.stackexchange.com/questions/ ... a-new-page

Using \displaybreak instead of \newpage should work.
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Post Reply