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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
  
Welcome to this tutorial on creating equations through latex. You see three windows as usual. I have created a 12pt size, article class document. And using AMSmath package and also using the ccliscences package for creative common copyright statement as here. Make title, creates the title page. New page command, takes the rest of the document to a new page.  
+
{| style="border-spacing:0;width:17.708cm;"
There are many ways to create equations, I will use the command align star to create equations. Let us begin with a matrix differential equation consisting of four components. Align star, Frac ,d by dt of begin b-matrix, x_1, next line, x_2,end b-matrix. Let me close this. Let us compile it. So we have created ‘d by dt of x1 x2’.  
+
|-
 +
| 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;" |
 +
| 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
 +
# Both equations.tex and numbers.tex should be sized
 +
# Both should be opened in Texworks
 +
# Both should be at the first line
 +
# equations.tex should be at the top, and numbers.tex should be below
 +
# Compile numbers.tex and get numbers.pdf
 +
# numbers.pdf should be sized
 +
# numbers.pdf should be scrolled all the way to the top
 +
# eqn-slides.pdf should be at the first slide
 +
# All should be arranged, as recorded in the tutorial
 +
# equations.tex should be directly below the slides file
  
Let us now augment the vector with two more components. You do it as follows.  Next line x3, next line x4. Save it. Compile it. So I have four components. Let me now say that this is equal to the right hand side matrix of begin b-matrix. Zero, zero, one, zero. Next line:  zero, zero, zero, one. And then, lets close this matrix.  Save. So I have this.
 
So I have written the first two rows. It is always a good idea to compile after very few small additions so that we have not made a mistake. Note that the align star environment takes the role of the dollar signs. For example, we did not enter the dollar sign at all.  As a matter of fact, we should not enter the dollar sign within the aligned star environment.
 
  
Let us add a third line to the matrix on the right hand side and illustrate this idea. Zero, dollar minus gamma, zero, zero. So there are four entries. Compile it. It comes and says, missing dollar inserted. What we will do is, lets come here, get rid of these dollar signs. Save it. Exit compilation by this x. recompile it and note that minus gamma has come. So we need one more line here, we put that. Zero, alpha without dollar sign, zero, zero. Alright, now this is the way to do that.
+
|-
Lets complete this equation. I have a few more terms here. Let me just see if it is here, yes it is here. Let’s cut this. Put this here. Let’s see what happens when I compile this.  This is a model of an inverted pendulum.  
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
What do you do when you have more than one equation?  Let us add one more aligned statement. And I have written this equation here. Let me bring it from there. Here is the equation, so let me say begin align star. Let’s cut this. Copy this. Close this align. We compile it. When I compile it, I get the second equation appearing.
+
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" | Texworks: Lucida
 +
| 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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | Welcome to this tutorial on writing equations using LaTeX
  
There are two problems with this. There is a large gap between the two equations and also we may want to align the equations. In view of these observations, we put both of these equations into a single align star environment. So we will do this as follows. Delete this. Save this. Compile it. Now what has happened is that both the equations have come on the same line. We will take care of that by telling latex to split this by the reverse slash.  Two of them. When I compile it, now these have gone to second equation.  But the equations are not aligned.  Suppose we want to align the equal to sign. Suppose we want to align these two signs, we put an ampersand symbol in front of the equal to signs here. Lets put it. And then we will put it here also. Ampersand. Let’s compile this. Now notice that both of them are aligned.  
+
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;" |
 +
| 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
  
Suppose we want to introduce some text in between the equations without upsetting the alignment. This can be achieved using the inter-text command.  So we remove, we made a mistake here, the delta mu has come here. So what we should do is, let us first, put this properly, compile this. Now delta mu has come there. U of t is here. Now we want introduce some text between these two. So the line separator slash, slash is removed and that place we introduce this text that we want to include. Let’s take this text  and put it there. Whatever text we want to put appears in braces with an inter-text command. Note that the opening brace has to be closed, not closing the brace is a common mistake made by the beginners. Lets compile this.  So here is the text and you also have the equations aligned. Note also the use of the dollar sign within the inter-text command. Inter-text is like running text, so this is not part of the align environment. You need to include dollars here.
 
  
These equations don’t have numbers. In fact, the star in the aligned star command has told latex not to put the equation numbers. Let us remove the star and see what the aligned environment does. Let’s remove the star here. Also remove the star here. Let’s see what happens. So equation numbers have appeared automatically. We want to refer to them, so for example, let’s say we want to refer to them, so I have this here. Suppose this is the second equation I want to discretize, So I write this statement. Let me take this here, below this, put it.  Let me compile it. So it says we will now discretize the PID controller given in equation 2.  The equation numbers unfortunately may change while insertion or deletion of equations.
+
Down arrow
  
To demonstrate this, let us suppose, we include an equation here. Slash, slash, A equals B. And then we will delete these lines. Let’s compile this. Now I have A equals B as the second equation. Now this has become the third equation. Here we have hardcoded that equation 2 has to be discretized but this is no longer the second equation. Hardcoding of equation numbers in referencing always has this problem. This is solved by the label command. So let us come here and here at the end of the equation we introduce ‘label equation PID’ and then here I write in equation ‘ref’, ref is the command, and whatever than comes here label, should appear here also,  again within the braces,’ equation PID’. Lets see what happens when I compile it. 
 
On compiling it, we see question marks here.  On second compilation see what happens here – now it has become three. On second compilation the numbers become correct. This is similar to what we saw in table of contents. Let us now delete the A equals B equation. Let us get rid of this also.  Let’s compile it. This equation 2 is gone, but you still have this three. ON first compilation the reference gives the previous number, on second compilation the numbers become correct. The labels are case sensitive. For example, here I have called it equation PID, PID is in capitals. Let’s change this to small PID. What happens now,  here it says that it doesn’t know that. Its only that these have to be identical, these need not be characters.  For example, suppose I want to give numbers here, let me just put hundred, let me put 100. Save it. Compile it. Okay, it doesn’t know it yet in the first compilation, but if I compile it a second time it will know. Numbers are the same.
 
  
In a similar way we can create labels for sections, sub-sections and so on. So let us do that, let us demonstrate this with section. Let us do it here. Section, this is first section. Label, sec 100. Then we go to the end of the document here. And says section ref sec-100, shows how to write equations. Save it. ‘Section, question marks shows how to write equations’. On next compilation this is taken care of. So section 1, this number is the same as this one. So this works for sections, sub-sections and so on. In fact with any environment that has a number associated with it. Alright, let’s delete these. Lets compile these. Once again. Alright.
+
Down arrow
  
We will now see how to accommodate long equations. So I have already written it here. Let me just go there at the end of the document, okay here it is.  Let me add this.  Put it here. Lets see what happens when I compile it.  So I have a third equation that I have added here, it’s a long equation. It’s a long equation so it doesn’t fit into one line. So let us break it into two. The way to do that is, let us break it here, slash, slash, and come here and I’m putting an aligned with this ampersand. Let me save it, Compile it. See that this equation has been broken into two parts and I am aligning it with the plus sign. All these equal signs and plus signs are aligned now.  Unfortunately we have equation numbers in both parts. Supposing we don’t want the number in the first line, suppose we don’t want this number. Include the command ‘no number’ before this slash, slash symbol. Do this as follows. Save this. Compile this. See that this equation number is gone and this has become three.
 
We see that the braces we wanted in some terms are missing. For example here I have said E N, E N minus 1. Here it appears without these braces. This is because, braces are delimiters in latex. We now want to tell latex to not interpret these braces. This is done by putting a reverse slash before the braces. Let me put a reverse slash here. Let me also put a reverse slash here. See that we have the braces here similarly lets put it here also. Here and here. Save this, now we have got that.   
 
We will now show to create large graphics in equations. For example here, these brackets are very small. The way to do that is using – what are known as left and right commands.  So lets come here – so the equation is here. The way to do this is – K slash left and on this side I have this, so here I put slash right. Let’s compile this. See this, it has become bigger. We can do this also with square brackets. I got square brackets. I can also put braces, only thing is that I have to tell latex not to interpret. So I put a slash brace. Let’s compile this. See this braces.
 
  
When we have one equation split into multiple lines, we will have to put only the left on the first. For example, we have a bracket here and a bracket here, I want to make this slightly bigger. So let me do that here. Suppose for example, I want to put a left bracket here and here I want to put a right bracket. Compile it. It comes and complains ‘forgotten right’, because I opened it here but I didn’t close it in the same equation. The way to do that is to use what is known as slash right dot, that means don’t worry about the right hand side. Similarly , here we have to say slash left dot, don’t worry about the left here. Let me exit here. Let me re-compile it. So this is taken care of.
+
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
  
Now suppose I want to push this a little inside. I can always says slash h-space 1cm. let me just do that shift. So this has been shifted, this has been aligned. If you don’t want this, you want the plus sign to come inside. Let’s do this here, put the plus sign here. Okay, this plus is now inside. Now this is nicely done. 
+
How to write <u>multiple</u> equations
  
All commands that work in between the dollar sign also work between the aligned environment but for the ampersand symbol that is used for the aligning of multiple symbols. All commands that work in the aligned environment also work within the dollar symbols. Nevertheless, there is a small difference in the way some outputs appear in the aligned environment and in the running mode obtained with the dollar. This can be illustrated with the integral mode. So lets come here. Let’s delete this. So I have this statement here.  Let me take this, let me put it here. The integral mode includes the term this integral. Let me close this otherwise alignment will complain.  So what I have done is the integral mode includes the term this integral. Note the size of this integral size and this integral. This is a lot bigger and this is smaller.
+
How to <u>align</u> multiple equations and
  
Such changes also occur in the case of fractions, sum and product to cite a few. There is one other thing that I want to tell before completing this tutorial. Aligned environment does not like blank lines in between. Suppose for example, I create a blank line here. It comes and says that paragraph ended before alignment was complete. If you really want a space, leave a percentage which tells latex that it is not common. Re-compiling. It goes through and you get all the text as before.  
+
Why we should avoid the dollar mode and blank lines while writing equations
This brings us to the end of this tutorial. Thanks for listening. This is Kannan Moudgalya signing off. Good-bye.
+
|-
 +
| 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;" | System requirements 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;" | One may use any of Linux, Windows or the Mac operating system
 +
 
 +
One needs LaTeX
 +
 
 +
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;" |
 +
| 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
 +
 
 +
 
 +
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?
 +
 
 +
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
 +
|-
 +
| 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;" | Additional material slide
 +
 
 +
Open in Texworks
 +
 
 +
 
 +
Back to slides file, 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>
 +
 
 +
 
 +
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
 +
 
 +
If you don't have it, please download it from the Spoken Tutorial website
 +
|-
 +
| 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;" | Slide on Leslie Lamport’s book
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
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;" |
 +
| 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;" |
 +
| 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
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Open numbers.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;" | 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
 +
 
 +
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 <u>equations.tex</u>
 +
 
 +
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;" |
 +
| 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
 +
| 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;" |
 +
| style="border-top:none;border-bottom:0.05pt solid #000000;border-left:0.05pt solid #000000;border-right:none;padding:0.097cm;" |
 +
 
 +
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
 +
| 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
 +
 
 +
You can see how it gets typeset in the pdf file
 +
 
 +
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;" |
 +
| 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 the x_1 line
 +
 
 +
 
 +
Click on the eqn
 +
 
 +
 
 +
Click on matrix pdf
 +
 
 +
 
 +
Click on matrix tex
 +
 
 +
 
 +
Delete row 1 compile
 +
 
 +
 
 +
 
 +
 
 +
Click the pdf
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
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
 +
 
 +
 
 +
On the left hand side, we have the derivative of a vector
 +
 
 +
We can see the pdf output here
 +
 
 +
On the right hand side, we have a 3 by 3 matrix
 +
 
 +
See the corresponding output
 +
 
 +
Suppose we delete the first row in this matrix and compile
 +
 
 +
 
 +
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
 +
 
 +
Let me put the row back
 +
 
 +
 
 +
Let me compile
 +
 
 +
You can also add more rows, if necessary
 +
 
 +
Similarly, you can change the columns too
 +
|-
 +
| 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;" |
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
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;" |
 +
 
 +
 
 +
 
 +
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
 +
 
 +
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;" |
 +
| 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*}
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Put the text into \intertext{}
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
Compile
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | 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
 +
|-
 +
| 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
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | This is where we will stop
 +
 
 +
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;" |
 +
| 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
 +
| 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
 +
 
 +
Please recall each of these commands
 +
 
 +
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;" |
 +
| 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
 +
| 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
 +
 
 +
Can you pause the video and try to produce these equations?
 +
 
 +
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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | Can you produce these equations?
 +
 
 +
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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | 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!
 +
|-
 +
| 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;" | Assignment 5
 +
| 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
 +
|-
 +
| 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;" | Assignment 6
 +
| 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
 +
 
 +
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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | I have the last assignment in this slide
 +
 
 +
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;" |
 +
| 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:0.05pt solid #000000;padding:0.097cm;" | I will now give some general information
 +
 
 +
 
 +
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;" |
 +
| 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: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;" |
 +
| 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
 +
 
 +
Down arrow
 +
 
 +
Down arrow
 +
 
 +
Down arrow
 +
 
 +
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
 +
* 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
 +
|-
 +
| 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;" | Where to post 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;" | 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;" |
 +
| 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: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;" |
 +
| 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: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;" |
 +
| 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
 +
|-
 +
|}

Revision as of 14:41, 16 October 2019

Initial conditions # Copy equations.tex into numbers.tex
  1. Both equations.tex and numbers.tex should be sized
  2. Both should be opened in Texworks
  3. Both should be at the first line
  4. equations.tex should be at the top, and numbers.tex should be below
  5. Compile numbers.tex and get numbers.pdf
  6. numbers.pdf should be sized
  7. numbers.pdf should be scrolled all the way to the top
  8. eqn-slides.pdf should be at the first slide
  9. All should be arranged, as recorded in the tutorial
  10. equations.tex should be directly below the slides file


Texworks: Lucida Grande, 22pt, 20px. Preview: 75%, 200dpi
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

Open in Texworks


Back to slides file, press down arrow


Press down arrow


Press down arrow

I shall use equations.tex


I have opened it in Texworks


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 website

Slide on Leslie Lamport’s book






Web browser is opened

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

Let us begin the tutorial
Open equations.tex








Open numbers.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

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

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

Change 7 to 15


Put back 7


Click amsmath line


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

Click the first align





click u(t) line in tex


click u(t) on slide



Hover on \left and click \right

I write the first equation within the align star environment, as shown here

You can see how it gets typeset in the pdf file

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

Scroll the tex file up


Click align* line


Click the x_1 line


Click on the eqn


Click on matrix pdf


Click on matrix tex


Delete row 1 compile



Click the pdf





Undo the last command in tex

Similarly, I write a second equation using align star


On the left hand side, we have the derivative of a vector

We can see the pdf output here

On the right hand side, we have a 3 by 3 matrix

See the corresponding output

Suppose we delete the first row in this matrix and compile


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

Let me put the row back


Let me compile

You can also add more rows, if necessary

Similarly, you can change the columns too








Put $ and compile


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


Below the line with alpha, leave a blank line



Put %

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

Let us remove this line and compile





Remove \end{align*}


Remove \begin{align*}










Put the text into \intertext{}








Compile







Put & sign before =


Repeat in the 2nd eqn.





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 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 intertext command

Let us put the text in between braces

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

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

Do not forget the back slash before intertext

Also, do not forget the closing brace

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

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









Put \\


Compile


Undo

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 back slashes

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

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