Difference between revisions of "LaTeX/C2/Equations/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
  
{| style="border-spacing:0;width:17.708cm;"
+
{| border = 1
 
|-
 
|-
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Initial conditions
| style="border-top:0.05pt solid #000000;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Initial conditions
+
||  
| style="border:0.05pt solid #000000;padding:0.097cm;" | # Copy equations.tex into numbers.tex
+
# Copy equations.tex into numbers.tex
 
# Both equations.tex and numbers.tex should be sized
 
# Both equations.tex and numbers.tex should be sized
# Both should be opened in Texworks
+
# Both should be opened in TeXworks
 
# Both should be at the first line
 
# Both should be at the first line
 
# equations.tex should be at the top, and numbers.tex should be below
 
# equations.tex should be at the top, and numbers.tex should be below
Line 15: Line 15:
 
# All should be arranged, as recorded in the tutorial
 
# All should be arranged, as recorded in the tutorial
 
# equations.tex should be directly below the slides file
 
# equations.tex should be directly below the slides file
 +
|-
 +
|| TeXworks: Lucida
 +
|| Grande, 22pt, 20px. Preview: 75%, 200dpi
 +
|-
 +
|}
 +
<br>
 +
<br>
  
 
+
{| border = 1
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||'''Visual Cue'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Texworks: Lucida
+
||'''Narration'''
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Grande, 22pt, 20px. Preview: 75%, 200dpi
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Opening slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Opening slide
+
|| Welcome to this tutorial on writing equations using '''LaTeX'''.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Welcome to this tutorial on writing equations using LaTeX
+
  
My name is Kannan Moudgalya
+
My name is Kannan Moudgalya.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Learning objectives slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Learning objectives slide
+
 
+
  
 
Down arrow
 
Down arrow
 
  
 
Down arrow
 
Down arrow
 
  
 
Down arrow
 
Down arrow
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | In this tutorial, we will learn how to create <u>an</u> equation in LaTeX
+
|| In this tutorial, we will learn  
 +
*How to create an equation in '''LaTeX'''.
  
How to write <u>multiple</u> equations
+
*How to write multiple equations
  
How to <u>align</u> multiple equations and
+
*How to align multiple equations and
  
Why we should avoid the dollar mode and blank lines while writing equations
+
*Why we should avoid the '''dollar mode''' and blank lines while writing equations
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| System requirements slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | System requirements slide
+
|| One may use any of '''Linux, Windows''' or the '''Mac''' operating system.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | One may use any of Linux, Windows or the Mac operating system
+
  
One needs LaTeX
+
One needs '''LaTeX'''.
  
I shall use Texworks, although it is not required
+
I shall use '''TexWorks''', although it is not required.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Prerequisites slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Prerequisites slide
+
 
+
 
+
 
+
  
 
Press Down arrow
 
Press Down arrow
 
  
 
Down arrow
 
Down arrow
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | What are the prerequisites?
+
|| What are the prerequisites?
  
One needs to be familiar with spoken tutorials that introduce LaTeX
+
One needs to be familiar with spoken tutorials that introduce '''LaTeX'''.
  
Exposure to the recommended method of side-by-side learning
+
Exposure to the recommended method of '''side-by-side learning'''.
  
This information is available at the Spoken Tutorial webpage
+
This information is available at the '''Spoken Tutorial''' webpage.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
|| Additional material slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Additional material slide
+
|| I shall use the file '''equations.tex'''
  
Open in Texworks
+
|-
 
+
||Open in TeXworks
 
+
||I have opened it in '''TeXworks'''.
Back to slides file, press down arrow
+
  
 +
|-
 +
||Back to slides file, press down arrow
  
 
Press down arrow
 
Press down arrow
 
  
 
Press down arrow
 
Press down arrow
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | I shall use <u>equations.tex</u>
+
||It is available as a code file along with this tutorial.
 
+
 
+
I have opened it in Texworks
+
 
+
 
+
It is available as a <u>code file</u> along with this tutorial
+
  
You need to have it to practise along with me
+
You need to have it to practise along with me.
  
If you don't have it, please download it from the Spoken Tutorial website
+
If you don't have it, please download it from the '''Spoken Tutorial webpage'''.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Slide on Leslie Lamport’s book
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Slide on Leslie Lamport’s book
+
  
  
 +
|| I will next call your attention to this standard textbook by '''Leslie Lamport'''.
  
 +
I learnt my '''LaTeX''' from this book.
  
 +
It is available for about Rs. 500.
  
 +
|-
 +
||Web browser is opened
 +
||Let me show on the web browser where one can buy it.
  
 
 
 
 
Web browser is opened
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | I will next call your attention to this standard textbook by Leslie Lamport
 
 
I learnt my LaTeX from this book
 
 
It is available for about Rs. 500
 
 
Let me show on the web browser where one can buy it
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Let us begin this tutorial
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Let us begin the tutorial
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Open equations.tex
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Open equations.tex
+
  
  
 +
|| Let us learn how to write equations using '''LaTeX'''.
  
 +
I have already opened the file '''equations.tex''' in '''TeXworks'''.
  
 +
I have saved it as '''numbers.tex''' to use in this tutorial.
  
 +
I will keep the file '''equations.tex''' intact, and not change it.
  
 +
|-
 +
||Open numbers.tex
 +
||Let me open '''numbers.tex'''
  
 +
|-
 +
||
 +
||Please pause the tutorial, make this copy and open it.
  
 +
Whenever you want to start afresh, you can make a new copy of '''equations.tex'''
  
 +
I recommend this method whenever a code file is given with ANY spoken tutorial.
 +
|-
 +
|| Press the '''Typeset''' key
 +
|| Let us '''compile''' this file by pressing the '''Typeset''' arrow at the top left hand corner.
  
 +
|-
 +
||Pdf file
 +
||You can see the '''pdf file''' on the right.
  
 +
|-
 +
||Switch to the tex file.
 +
||Let us look at the '''tex''' file, which begins with its usual '''commands'''.
  
 +
|-
 +
||Highlight 8cm
 +
||I have chosen the width of the '''pdf file''' to be 8cm.
  
 +
This is the only way I can show the entire file and also use a large font.
 +
|-
 +
||
  
Open numbers.tex
+
Change 8 to 15
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Let us learn how to write equations using LaTeX
+
  
I have already opened the file equations.tex in TeXworks.
+
Put back 8
  
I have saved it as numbers.tex to use in this tutorial
+
|| You may want to increase it to a more reasonable value, such as 15cm.
  
I will keep the file equations.tex intact, and not change it
+
But I will continue to use 8cm.
  
Let me open numbers.tex
+
|-
 +
||Click amsmath line
 +
||I am using the '''package amsmath'''.
  
Please pause the tutorial, make this copy and open it
+
|-
 +
|| Click the first align
 +
|| I write the first equation within the '''align star environment''', as shown here.
  
Whenever you want to start afresh, you can make a new copy of <u>equations.tex</u>
+
|-
 +
||Switch to the pdf and highlight the equation.
 +
||You can see how it gets '''typeset''' in the '''pdf file'''.
  
I recommend this method whenever a code file is given with ANY spoken tutorial
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||Click u(t) line in tex
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Press the typeset key
+
||On the left hand side of this equation, we have '''u of t'''.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Let us compile this file by pressing the typeset arrow at the top left hand corner
+
  
You can see the pdf file on the right
 
 
Let us look at the tex file, which begins with its usual commands
 
 
I have chosen the width of the pdf file to be 8cm
 
 
This is the only way I can show the entire file and also use a large font
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||Click u(t) in the pdf file
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||On the right hand side, I have produced big square brackets.
 
+
Change 7 to 15
+
 
+
 
+
Put back 7
+
 
+
 
+
Click amsmath line
+
 
+
 
+
 
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | You may want to increase it to a more reasonable value, such as 15cm
+
 
+
But I will continue to use 8cm
+
  
I am using the package amsmath
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Click the first align
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
click u(t) line in tex
+
 
+
 
+
click u(t) on slide
+
 
+
 
+
  
  
 
Hover on \left and click \right
 
Hover on \left and click \right
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | I write the first equation within the align star environment, as shown here
+
||How did I do this?
  
You can see how it gets typeset in the pdf file
+
With '''back slash left square''' and '''back slash right square''' brackets as shown here.
 
+
On the left hand side of this equation, we have u(t)
+
 
+
On the right hand side, I have produced big square brackets
+
 
+
How did I do this?
+
 
+
With “back slash left square” and “back slash right square” brackets as shown here
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Scroll the tex file up
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Scroll the tex file up
+
  
  
 
Click align* line
 
Click align* line
 +
|| Similarly, I write a second equation using '''align star'''.
  
 +
|-
 +
||Click the x_1 line
 +
||On the left hand side, we have the '''derivative''' of a '''vector'''.
  
Click the x_1 line
+
|-
 
+
||Click on the eqn in the pdf file
 
+
||We can see the '''pdf output''' here.
Click on the eqn
+
 
+
 
+
Click on matrix pdf
+
 
+
 
+
Click on matrix tex
+
 
+
 
+
Delete row 1 compile
+
  
 +
|-
 +
||Click on matrix tex
 +
|| On the right hand side, we have a '''3 by 3 matrix'''.
  
 +
|-
 +
||Click on matrix pdf
 +
||See the corresponding output.
  
 +
|-
 +
||Delete row 1 compile
 +
||Suppose we delete the first row in this '''matrix''' and '''compile'''.
  
 +
|-
 +
||
 
Click the pdf
 
Click the pdf
  
  
  
 +
||We get a '''2 by 3 matrix pdf output'''.
  
 +
The first line is gone.
  
 +
It is your responsibility to make the equations correct and consistent.
  
 +
|-
 +
||Undo the last command in tex
 +
||Let me put the row back.
  
 +
|-
 +
||Compile
 +
||Let me '''compile'''.
  
Undo the last command in tex
+
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Similarly, I write a second equation using align star
+
||
 +
||You can also add more rows, if necessary.
  
 +
Similarly, you can change the columns, too.
  
On the left hand side, we have the derivative of a vector
+
|-
 +
||
 +
|| Recall that we used the '''dollar mode''' to write formulae in another tutorial.
  
We can see the pdf output here
+
|-
 +
||Click on '''begin align''' in tex
 +
||Here, '''align''' plays the role of the '''dollar mode'''.
  
On the right hand side, we have a 3 by 3 matrix
+
In fact, one should not put the '''dollar sign''' within the '''align environment'''.
  
See the corresponding output
+
|-
 +
||Put $ and compile
  
Suppose we delete the first row in this matrix and compile
 
  
 +
||Suppose we put the '''alpha symbol''' within '''$ signs''' and '''compile'''.
  
We get a 2 by 3 matrix pdf output
+
|-
 +
||Error message
 +
||We get an error message about '''dollar'''.
  
The first line is gone
+
|-
 +
||Press red cross symbol to abort
 +
||Press the cross symbol on the top left red box and abort the previous '''compilation'''.
  
It is your responsibility to make the equations correct and consistent
+
|-
 
+
||Remove '''$ signs'''
Let me put the row back
+
||Let us remove the '''dollar''' sign.
 
+
 
+
Let me compile
+
 
+
You can also add more rows, if necessary
+
  
Similarly, you can change the columns too
+
'''Compile''' again, it works!
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Below the line with alpha, leave a blank line
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
  
  
  
 +
|| Another common mistake is leaving blank lines in the '''align environment'''.
  
 +
Let me leave an empty line and '''compile'''.
  
 +
|-
 +
||Error message
 +
||It gives an error message.
  
 +
|-
 +
||Put %
 +
||If you need this gap, put '''%''', the '''comment''' character, in the first column.
  
 +
|-
 +
||Press red cross symbol to abort
 +
||Abort '''compiling'''.
  
 +
|-
 +
||Press Typeset symbol to compile
 +
||'''Compile''' again - it '''compiles ok'''.
  
 +
So it is important to remember that you should not leave a blank line within the '''align statement'''.
  
 +
|-
 +
||Remove the blank line
 +
||Let me remove this line and '''compile'''.
  
 
 
 
 
Put $ and compile
 
 
 
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Recall that we used the $ mode to write formulae in another tutorial
 
 
Here, align plays the role of the $ mode
 
 
In fact, one should not put the dollar sign within the align environment
 
 
Suppose we put the alpha symbol within $ signs and compile
 
 
 
We get an error message about $
 
 
Press the cross symbol on the top left red box
 
 
And abort the previous compilation
 
 
Let us remove the $ signs
 
 
Compile again, it works
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||Next, I want to align the two equations by the '''equal to''' sign.
 
+
 
+
 
+
Below the line with alpha, leave a blank line
+
 
+
 
+
 
+
 
+
Put %
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Another common mistake is leaving blank lines in the align environment
+
 
+
Let me leave an empty line and compile
+
 
+
It gives an error message
+
 
+
If you need this gap, put %, the comment character, in the first column
+
 
+
Abort compilation
+
  
Compile again - we see that it works
+
For this, we need to put both equations inside one '''align star environment'''.
  
Let us remove this line and compile
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
|| Remove \end{align*}
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
Remove \end{align*}
+
 
+
  
 
Remove \begin{align*}  
 
Remove \begin{align*}  
 +
|| Remove the end '''align* command''' of the first equation.
  
 +
Remove the begin '''align* command''' of the second equation.
  
 +
|-
 +
||Compile
 +
|| Let us '''compile'''.
  
 +
|-
 +
||In the pdf file
 +
||We see only one equation appearing.
  
 +
The text in between the two equations appears as a large string.
  
 +
The second equation does not even show up.
  
 +
|-
 +
||
 +
|| This is not what we wanted.
  
 +
This problem is solved with the help of the '''intertext command'''.
  
 +
|-
 +
||Add braces before and after the text.
 +
||Let us put the text in between braces.
  
 +
|-
 +
||Put the text into \intertext{}
  
  
  
  
 +
||Let us also put this '''command, back slash intertext''' as I type now.
  
 +
Note that '''intertext''' is one word, without a space in between.
  
 +
|-
 +
||Point to the '''\'''
 +
||Do not forget the '''back slash''' before '''intertext'''.
  
 +
|-
 +
||Point to the closing brace
 +
||Also, do not forget the closing brace.
  
 +
These are all common mistakes.
  
Put the text into \intertext{}
+
|-
 +
||Compile
  
  
Line 385: Line 359:
  
  
 +
||On compiling, we get this '''pdf''' file.
  
 +
You see both equations now.  But unfortunately, you see both the equations right aligned.
  
 +
Not aligned by the '''equal to''' sign.
  
 +
|-
 +
||
 +
||So, I am not happy with it.
  
 +
I want to align by the '''equal to''' sign.
  
 +
|-
 +
||Put & sign before =
  
 +
||To do this, let us put the '''ampersand''' sign in front of the '''equal to''' sign.
  
 +
Let's do it for the first equation.
  
 +
|-
 +
||Repeat in the 2<sup>nd</sup> eqn.
  
Compile
 
  
  
 +
||And then let's do it for the second equation.
  
 +
If you have more equations to be aligned, do this for all of them.
  
 
 
 
 
 
 
 
 
Put & sign before =
 
 
 
Repeat in the 2<sup>nd</sup> eqn.
 
 
 
 
 
 
 
 
 
Compile
 
 
 
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Next, I want to align the two equations by the equal to sign
 
 
For this, we need to put both equations inside one align star environment
 
 
Remove the end align* command of the first equation
 
 
Remove the begin align* command of the second equation
 
 
 
Let us compile
 
 
We see only one equation appearing
 
 
The text in between the two equations appears as a large string
 
 
The second equation does not even show up
 
 
This is not what we wanted
 
 
This problem is solved with the help of the <u>intertext </u>command
 
 
Let us put the text in between braces
 
 
Let us also put this command <u>back slash intertext</u> as I type now
 
 
Note that <u>intertex</u>t is one word, without a space in between
 
 
Do not forget the <u>back slash</u> before intertext
 
 
Also, do not forget the <u>closing brace</u>
 
 
These are all common mistakes
 
 
On compiling, we get this pdf file
 
 
You see the equations right aligned
 
 
I am not happy with it
 
 
I want to align by the equal to sign
 
 
Let us put the ampersand sign in front of the equal to sign of the first equation
 
 
Let us do it on the second equation also
 
 
If you have more equations to be aligned, do this for all of them
 
 
On compiling, we see the two equations aligned by the equal to sign
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||Compile
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||On '''compiling''', we see the two equations aligned by the '''equal to''' sign.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | The equations are aligned even though there is text in between.
+
|-
 +
||  
 +
|| The equations are aligned even though there is text in between.
  
Remember to use the <u>intertext</u> command whether you want the equations aligned or not
+
Remember to use the '''intertext command''' whether you want the equations aligned or not.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
 
+
 
+
 
+
 
Delete text lines
 
Delete text lines
 +
|| What do we do if we don’t have text between equations?
  
 +
To understand this, let us delete the entire text between the two equations.
  
 +
|-
 +
||Put \\
 +
||Note that we should not leave an empty line.
  
 +
|-
 +
||Compile
 +
||On '''compiling''', we see both equations coming in the same line.
  
 +
We didn’t tell '''LaTeX''' to start the second equation in the next line.
  
 +
|-
 +
||Add '''\\'''
 +
||We solve this by putting two '''back slashes''' at the end of the first equation.
  
 +
|-
 +
||Compile
 +
||Let us compile, to get the correct '''pdf''' file.
  
 +
|-
 +
||Undo
 +
||Let us now undo and put the text in between two equations.
  
 
 
 
 
 
 
 
 
Put \\
 
 
 
Compile
 
 
 
Undo
 
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | What do we do if we don’t have text between equations?
 
 
To understand this, let us delete the entire text between the two equations
 
 
Note that we should not leave an empty line
 
 
On compiling, we see both equations coming in the same line
 
 
We didn’t tell LaTeX to start the second equation in the next line
 
 
We solve this by putting two <u>back slashes</u>
 
 
Let us compile, to get the correct pdf file
 
 
Let us now undo and put the text in between two equations
 
 
Let us compile once more
 
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||Compile
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||Let us '''compile''' once more.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | This is where we will stop
+
|-
 +
||  
 +
|| This is where we will stop.
  
Let me go to the slides
+
Let me go to the slides.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Summary slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Summary slide
+
  
 
Down arrow
 
Down arrow
  
 
Down arrow
 
Down arrow
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | This page summarises what we learnt in this tutorial
+
|| This page summarises what we learnt in this tutorial.
  
Please recall each of these commands
+
Please recall each of these '''commands'''.
  
This is your first assignment
+
This is your first assignment.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| More assignments slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | More assignments slide
+
  
 
Down arrow
 
Down arrow
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | I will give some more assignments
+
|| I will give some more assignments.
  
 
Can you pause the video and try to produce these equations?
 
Can you pause the video and try to produce these equations?
  
The required code is given here
+
The required code is given here.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Assignment 3
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Assignment 3
+
|| Can you produce these equations?
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Can you produce these equations?
+
  
Notice that these equations are now aligned at the equal to sign
+
Notice that these equations are now aligned at the '''equal to''' sign.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Assignment 4
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Assignment 4
+
|| What happens if you forget a required '''ampersand''' sign?
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | What happens if you forget a required ampersand sign?
+
  
Please pause the video and try this input
+
Please pause the video and try this input.
  
You should get this output
+
You should get this output.
  
Forgetting ampersand signs is a common mistake made by everyone!
+
Forgetting '''ampersand''' signs is a common mistake made by everyone!
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Assignment 5
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Assignment 5
+
|| Can you pause this video and try to produce this output?
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Can you pause this video and try to produce this output?
+
  
Use the hint given here
+
Use the hint given here.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Assignment 6
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Assignment 6
+
|| In this assignment, you have to align three equations.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | In this assignment, you have to align three equations
+
  
Please pause the video here, and try to produce them by yourself
+
Please pause the video here, and try to produce them by yourself.
  
I have given the answer here
+
I have given the answer here.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Assignment 7
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Assignment 7
+
|| I have the last assignment in this slide.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | I have the last assignment in this slide
+
  
Insert some text between equations
+
Insert some text between equations.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| About the ST slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | About the ST slide
+
|| I will now give some general information.
 
+
 
+
 
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | I will now give some general information
+
 
+
 
+
This video summarises the '''Spoken Tutorial''' project
+
 
+
 
+
  
 +
This video summarises the '''Spoken Tutorial project'''.
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Workshops slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Workshops slide
+
|| We conduct workshops using '''Spoken Tutorials'''.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | We conduct workshops using '''Spoken Tutorials'''
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Answers slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Answers slide
+
  
 
Press down arrow
 
Press down arrow
Line 618: Line 503:
  
 
Down arrow twice
 
Down arrow twice
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Do you have questions in <u>THIS</u> '''Spoken Tutorial?''' * Please visit this site
+
|| Do you have questions in <u>THIS</u> '''Spoken Tutorial?'''  
 +
* Please visit this site
 
* Choose the minute and second where you have the question
 
* Choose the minute and second where you have the question
 
* Explain your question briefly
 
* Explain your question briefly
Line 624: Line 510:
  
  
 
+
You will have to register on this website to ask questions.
You will have to register on this website to ask questions
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Where to post slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Where to post slide
+
|| For topics not covered in spoken tutorials, visit '''stack exchange''' at this address.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | For topics not covered in spoken tutorials, visit '''stack exchange''' at this address  
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Contact us slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Contact us slide
+
|| For any other questions, please contact us.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | For any other questions, please contact us
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Acknowledgement slide
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Acknowledgement slide
+
|| '''Spoken Tutorial''' project is funded by MHRD, Government of India.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | '''Spoken Tutorial''' project is funded by MHRD, Government of India
+
 
|-
 
|-
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |  
+
||  
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
+
|| Thanks for joining.
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:0.05pt solid #000000;padding:0.097cm;" | Thanks for joining
+
  
Goodbye
+
Goodbye.
 
|-
 
|-
 
|}
 
|}

Latest revision as of 19:24, 22 October 2019

Initial conditions
  1. Copy equations.tex into numbers.tex
  2. Both equations.tex and numbers.tex should be sized
  3. Both should be opened in TeXworks
  4. Both should be at the first line
  5. equations.tex should be at the top, and numbers.tex should be below
  6. Compile numbers.tex and get numbers.pdf
  7. numbers.pdf should be sized
  8. numbers.pdf should be scrolled all the way to the top
  9. eqn-slides.pdf should be at the first slide
  10. All should be arranged, as recorded in the tutorial
  11. equations.tex should be directly below the slides file
TeXworks: Lucida Grande, 22pt, 20px. Preview: 75%, 200dpi



Visual Cue Narration
Opening slide Welcome to this tutorial on writing equations using LaTeX.

My name is Kannan Moudgalya.

Learning objectives slide

Down arrow

Down arrow

Down arrow

In this tutorial, we will learn
  • How to create an equation in LaTeX.
  • How to write multiple equations
  • How to align multiple equations and
  • Why we should avoid the dollar mode and blank lines while writing equations
System requirements slide One may use any of Linux, Windows or the Mac operating system.

One needs LaTeX.

I shall use TexWorks, although it is not required.

Prerequisites slide

Press Down arrow

Down arrow

What are the prerequisites?

One needs to be familiar with spoken tutorials that introduce LaTeX.

Exposure to the recommended method of side-by-side learning.

This information is available at the Spoken Tutorial webpage.

Additional material slide I shall use the file equations.tex
Open in TeXworks I have opened it in TeXworks.
Back to slides file, press down arrow

Press down arrow

Press down arrow

It is available as a code file along with this tutorial.

You need to have it to practise along with me.

If you don't have it, please download it from the Spoken Tutorial webpage.

Slide on Leslie Lamport’s book


I will next call your attention to this standard textbook by Leslie Lamport.

I learnt my LaTeX from this book.

It is available for about Rs. 500.

Web browser is opened Let me show on the web browser where one can buy it.
Let us begin this tutorial
Open equations.tex


Let us learn how to write equations using LaTeX.

I have already opened the file equations.tex in TeXworks.

I have saved it as numbers.tex to use in this tutorial.

I will keep the file equations.tex intact, and not change it.

Open numbers.tex Let me open numbers.tex
Please pause the tutorial, make this copy and open it.

Whenever you want to start afresh, you can make a new copy of equations.tex

I recommend this method whenever a code file is given with ANY spoken tutorial.

Press the Typeset key Let us compile this file by pressing the Typeset arrow at the top left hand corner.
Pdf file You can see the pdf file on the right.
Switch to the tex file. Let us look at the tex file, which begins with its usual commands.
Highlight 8cm I have chosen the width of the pdf file to be 8cm.

This is the only way I can show the entire file and also use a large font.

Change 8 to 15

Put back 8

You may want to increase it to a more reasonable value, such as 15cm.

But I will continue to use 8cm.

Click amsmath line I am using the package amsmath.
Click the first align I write the first equation within the align star environment, as shown here.
Switch to the pdf and highlight the equation. You can see how it gets typeset in the pdf file.
Click u(t) line in tex On the left hand side of this equation, we have u of t.
Click u(t) in the pdf file On the right hand side, I have produced big square brackets.


Hover on \left and click \right

How did I do this?

With back slash left square and back slash right square brackets as shown here.

Scroll the tex file up


Click align* line

Similarly, I write a second equation using align star.
Click the x_1 line On the left hand side, we have the derivative of a vector.
Click on the eqn in the pdf file We can see the pdf output here.
Click on matrix tex On the right hand side, we have a 3 by 3 matrix.
Click on matrix pdf See the corresponding output.
Delete row 1 compile Suppose we delete the first row in this matrix and compile.

Click the pdf


We get a 2 by 3 matrix pdf output.

The first line is gone.

It is your responsibility to make the equations correct and consistent.

Undo the last command in tex Let me put the row back.
Compile Let me compile.
You can also add more rows, if necessary.

Similarly, you can change the columns, too.

Recall that we used the dollar mode to write formulae in another tutorial.
Click on begin align in tex Here, align plays the role of the dollar mode.

In fact, one should not put the dollar sign within the align environment.

Put $ and compile


Suppose we put the alpha symbol within $ signs and compile.
Error message We get an error message about dollar.
Press red cross symbol to abort Press the cross symbol on the top left red box and abort the previous compilation.
Remove $ signs Let us remove the dollar sign.

Compile again, it works!

Below the line with alpha, leave a blank line


Another common mistake is leaving blank lines in the align environment.

Let me leave an empty line and compile.

Error message It gives an error message.
Put % If you need this gap, put %, the comment character, in the first column.
Press red cross symbol to abort Abort compiling.
Press Typeset symbol to compile Compile again - it compiles ok.

So it is important to remember that you should not leave a blank line within the align statement.

Remove the blank line Let me remove this line and compile.
Next, I want to align the two equations by the equal to sign.

For this, we need to put both equations inside one align star environment.

Remove \end{align*}

Remove \begin{align*}

Remove the end align* command of the first equation.

Remove the begin align* command of the second equation.

Compile Let us compile.
In the pdf file We see only one equation appearing.

The text in between the two equations appears as a large string.

The second equation does not even show up.

This is not what we wanted.

This problem is solved with the help of the intertext command.

Add braces before and after the text. Let us put the text in between braces.
Put the text into \intertext{}



Let us also put this command, back slash intertext as I type now.

Note that intertext is one word, without a space in between.

Point to the \ Do not forget the back slash before intertext.
Point to the closing brace Also, do not forget the closing brace.

These are all common mistakes.

Compile



On compiling, we get this pdf file.

You see both equations now. But unfortunately, you see both the equations right aligned.

Not aligned by the equal to sign.

So, I am not happy with it.

I want to align by the equal to sign.

Put & sign before = To do this, let us put the ampersand sign in front of the equal to sign.

Let's do it for the first equation.

Repeat in the 2nd eqn.


And then let's do it for the second equation.

If you have more equations to be aligned, do this for all of them.

Compile On compiling, we see the two equations aligned by the equal to sign.
The equations are aligned even though there is text in between.

Remember to use the intertext command whether you want the equations aligned or not.

Delete text lines

What do we do if we don’t have text between equations?

To understand this, let us delete the entire text between the two equations.

Put \\ Note that we should not leave an empty line.
Compile On compiling, we see both equations coming in the same line.

We didn’t tell LaTeX to start the second equation in the next line.

Add \\ We solve this by putting two back slashes at the end of the first equation.
Compile Let us compile, to get the correct pdf file.
Undo Let us now undo and put the text in between two equations.
Compile Let us compile once more.
This is where we will stop.

Let me go to the slides.

Summary slide

Down arrow

Down arrow

This page summarises what we learnt in this tutorial.

Please recall each of these commands.

This is your first assignment.

More assignments slide

Down arrow

I will give some more assignments.

Can you pause the video and try to produce these equations?

The required code is given here.

Assignment 3 Can you produce these equations?

Notice that these equations are now aligned at the equal to sign.

Assignment 4 What happens if you forget a required ampersand sign?

Please pause the video and try this input.

You should get this output.

Forgetting ampersand signs is a common mistake made by everyone!

Assignment 5 Can you pause this video and try to produce this output?

Use the hint given here.

Assignment 6 In this assignment, you have to align three equations.

Please pause the video here, and try to produce them by yourself.

I have given the answer here.

Assignment 7 I have the last assignment in this slide.

Insert some text between equations.

About the ST slide I will now give some general information.

This video summarises the Spoken Tutorial project.

Workshops slide We conduct workshops using Spoken Tutorials.
Answers slide

Press down arrow

Down arrow

Down arrow

Down arrow

Down arrow twice

Do you have questions in THIS Spoken Tutorial?
  • Please visit this site
  • Choose the minute and second where you have the question
  • Explain your question briefly
  • Someone from our team will answer them


You will have to register on this website to ask questions.

Where to post slide For topics not covered in spoken tutorials, visit stack exchange at this address.
Contact us slide For any other questions, please contact us.
Acknowledgement slide Spoken Tutorial project is funded by MHRD, Government of India.
Thanks for joining.

Goodbye.

Contributors and Content Editors

Chandrika, Nancyvarkey, Pravin1389