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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 96: Line 96:
 
||
 
||
 
||I will keep the '''numbers.tex''' file intact, and not change it.
 
||I will keep the '''numbers.tex''' file intact, and not change it.
|-
 
||Open '''align.tex'''
 
||Let me open '''align.tex'''
 
 
|-
 
|-
 
||Narration only  
 
||Narration only  
Line 106: Line 103:
  
 
I recommend this method whenever a code file is given with ANY '''spoken tutorial'''.
 
I recommend this method whenever a code file is given with ANY '''spoken tutorial'''.
 +
|-
 +
||Open '''align.tex'''
 +
||Let me open '''align.tex'''
 
|-
 
|-
 
|| Press the '''Typeset''' key
 
|| Press the '''Typeset''' key
|| Let us compile this file by pressing the '''Typeset''' arrow at the top left hand corner.
+
|| 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.
 
You can see the '''pdf''' file on the right.
Line 172: Line 172:
 
||One consequence is that the second equation is now numbered as one.
 
||One consequence is that the second equation is now numbered as one.
 
|-
 
|-
|| Narration only
+
|| Highlight equation 2 in the running text
 
+
 
+
 
+
 
+
 
+
  
 
|| Unfortunately, the reference to the second equation has become wrong in the text.
 
|| Unfortunately, the reference to the second equation has become wrong in the text.
 
+
|-
Can we prevent such mistakes even if we have to add or remove equations?  
+
|Narration only
 +
||Can we prevent such mistakes even if we have to add or remove equations?  
  
 
Such a requirement occurs frequently while writing reports, theses, papers, etc.
 
Such a requirement occurs frequently while writing reports, theses, papers, etc.
Line 190: Line 186:
 
We have seen this in a previous tutorial also.
 
We have seen this in a previous tutorial also.
  
Let me put '''\label{PID}''' at the end of the second equation, but before '''end align'''.
+
Let me put '''slash label PID''' at the end of the second equation, but before '''end align'''.
 
|-
 
|-
 
|| Put \ref{PID}
 
|| Put \ref{PID}
|| Replace '''2''' in the running text with '''\ref{PID}''' as I do now.  
+
|| Replace '''2''' in the running text with '''slash ref PID''' as I do now.  
 
|-
 
|-
 
||Compile
 
||Compile
||After '''compiling''' once, two Question marks appear against the equation number.
+
||After '''compiling''' once, two question marks appear against the equation number.
 
|-
 
|-
 
||Compile again
 
||Compile again
||On compiling twice, the question marks get replaced by the correct number.
+
||On '''compiling''' twice, the question marks get replaced by the correct number.
 
|-
 
|-
 
|| Remove \nonumber
 
|| Remove \nonumber
|| Let us change the equation number once again by removing '''\nonumber'''.
+
|| Let us change the equation number once again by removing '''nonumber'''.
 
|-
 
|-
 
||Compile twice.
 
||Compile twice.
Line 217: Line 213:
 
|| The '''variable''' in the '''ref''' and '''label commands''' have to be identical.
 
|| The '''variable''' in the '''ref''' and '''label commands''' have to be identical.
  
Check what happens if you change '''PID''' in the '''ref command''' to lower case.
+
Check what happens if you change '''PID''' in the '''ref command''' to lowercase.
  
 
Leave the '''PID''' in uppercase in the '''label command''' and '''compile'''.
 
Leave the '''PID''' in uppercase in the '''label command''' and '''compile'''.
 
|-
 
|-
 
||Point to question mark
 
||Point to question mark
||We get question mark here because this lower case '''pid''' is not defined.
+
||We get question mark here because this lowercase '''pid''' is not defined.
  
I will put pid back in uppercase and compile
+
I will put pid back in uppercase and '''compile'''.
 
|-
 
|-
 
|| Narration
 
|| Narration
Line 244: Line 240:
 
||Let me go to a '''web browser'''.
 
||Let me go to a '''web browser'''.
  
Let me do a web search on the topic of LaTeX multiline
+
Let me do a web search on the topic of '''LaTeX multiline'''.
 
|-
 
|-
 
||Hover on stackexchange
 
||Hover on stackexchange
 
||The very first hit is on '''stackexchange'''.
 
||The very first hit is on '''stackexchange'''.
  
Let me click this '''“how to align”'''.
+
Let me click this '''“How to align...”'''.
 
|-
 
|-
 
||Scroll down the page
 
||Scroll down the page
 
||If you scroll down this page, you will see a question and several answers.
 
||If you scroll down this page, you will see a question and several answers.
  
Most answers present a complete code.
+
Most answers present a complete '''code'''.
 
|-
 
|-
 
|| Copy from top to bottom, not from bottom
 
|| Copy from top to bottom, not from bottom
Line 261: Line 257:
 
This number may be different when you access this page.
 
This number may be different when you access this page.
  
Below that, the '''pdf''' output created by this code is shown.
+
Below this, the '''pdf''' output created by this '''code''' is shown.
  
 
Let me paste it on the '''tex''' file.
 
Let me paste it on the '''tex''' file.
 
|-
 
|-
||  
+
|| Compile
 
|| Let us '''compile''' the '''tex''' file.
 
|| Let us '''compile''' the '''tex''' file.
  
Line 271: Line 267:
 
|-
 
|-
 
||  
 
||  
|| Please try all '''commands''' explained in this web page and understand them.
+
|| Please try all '''commands''' explained in this '''web page''' and understand them.
 
|-
 
|-
 
|| Remove the text between the begin and end document
 
|| Remove the text between the begin and end document
Line 280: Line 276:
 
You can practise this part even if you don’t have '''web access'''.
 
You can practise this part even if you don’t have '''web access'''.
 
|-
 
|-
||  
+
|| Scroll down the page >> Contents
|| Let us scroll and go to contents.
+
|| Let us scroll and go to '''Contents'''.
 
+
Let us click '''“typesetting mathematics”'''.
+
 
+
You can see many examples.
+
 
+
Let us go to page 87.
+
 
+
Let us copy '''“cases code”''' and paste it within the '''document environment'''.
+
 
+
On '''compiling''' it, we get the output given in '''ltxprimer'''.
+
 
|-
 
|-
||  
+
||Click on Typesetting Mathematics
 +
||Let us click '''“Typesetting Mathematics”'''.
 +
|-
 +
||Point to the examples.
 +
||You can see many examples.
 +
|-
 +
||Go to page 87
 +
||Let us go to page 87.
 +
|-
 +
||Copy and paste the code
 +
||Let us copy '''“cases code”''' and paste it within the '''document environment'''.
 +
|-
 +
||Compile
 +
|On '''compiling''' it, we get the output given in '''ltxprimer'''.
 +
|-
 +
|| Change equation* to align* >> Compile
 
|| You may change '''equation*''' to '''align*''', and '''compile'''.
 
|| You may change '''equation*''' to '''align*''', and '''compile'''.
  
Line 331: Line 332:
 
Hint: we saw this in an earlier tutorial.
 
Hint: we saw this in an earlier tutorial.
  
You can also locate an answer for this in '''ltxprimer.pdf''' - search for '''Cross References'''.
+
You can also locate an answer for this in '''ltxprimer.pdf''' file.
 +
 
 +
Search for '''Cross References'''.
 
|-
 
|-
 
|| Assignment 3
 
|| Assignment 3
|| Try examples from '''Chapter VIII''' of '''ltxprimer pdf''' file we saw earlier.
+
|| Try examples from '''Chapter 8''' of '''ltxprimer pdf''' file we saw earlier.
  
 
Try to understand them.
 
Try to understand them.
Line 370: Line 373:
  
  
You will have to register on this website to ask questions
+
You will have to register on this '''website''' to ask questions.
 
|-
 
|-
 
|| Where to post slide
 
|| Where to post slide
|| For topics not covered in spoken tutorials, visit '''stack exchange''' at this address.  
+
|| For topics not covered in spoken tutorials, visit '''stackexchange''' at this address.  
  
 
This is a great place to get answers on '''LaTeX'''.  
 
This is a great place to get answers on '''LaTeX'''.  
Line 383: Line 386:
 
|-
 
|-
 
||  
 
||  
|| '''Spoken Tutorial''' project is funded by MHRD, Government of India
+
|| '''Spoken Tutorial''' project is funded by MHRD, Government of India.
 
|-
 
|-
 
||  
 
||  
|| Thanks for joining
+
|| Thanks for joining.
  
Goodbye
+
Goodbye.
 
|-
 
|-
 
|}
 
|}

Revision as of 15:20, 28 October 2019

Initialisation:
  1. Copy numbers.tex into align.tex
  2. Both numbers.tex and align.tex should be sized
  3. Both should be opened in Texworks
  4. Both should be at the first line
  5. align.tex should be below numbers.tex
  6. Compile align.tex and get align.pdf
  7. align.pdf should be sized
  8. align.pdf should be scrolled all the way to the top
  9. num-slides.pdf should be at the first slide
  10. All should be arranged, as recorded in the tutorial
  11. numbers.tex should be directly below the slides file
  12. Blank web browser with search “latex multi”
  13. The resulting google page should be in right zoom
  14. ltxprimer pdf file should be open in the first page
  15. The name of the ltxprimer.pdf should be seen
  16. ltxprimer pdf file should be zoomed appropriately
  17. Check that you have Internet access



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

My name is Kannan Moudgalya.

Learning objectives slide In this tutorial, we will learn-
  1. How to put equation numbers
  2. How to remove them
  3. How to correctly reference equations
  4. How to use the information on the web
System requirements slide One may use any of Linux, Windows or a Mac operating system.

One needs LaTeX.

I shall use TeXworks.

Prerequisites slide

Press Down arrow


Down arrow

What are the prerequisites?
  1. One needs to be familiar with spoken tutorials that introduce LaTeX.
  2. We recommend the use of the Side-by-Side method.
  3. This information is available at the Spoken Tutorial webpage.
Additional material slide

Show equation.tex

Show ltxprimer pdf file


Back to slides file, press down arrow.

I shall use the following files:
  • numbers.tex, which you can see here.
  • ltxprimer pdf file from TUG India. It is here.


These are available as Code files along with this tutorial.

With these files, you will be able to practise along with me.

If you don't have these files, please download them from the Spoken Tutorial website.

Open numbers.tex Let us begin the tutorial.
Let us learn how to create numbers for equations in LaTeX.

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

Point to the title align.tex I have saved it as align.tex to use in this tutorial.
I will keep the numbers.tex file intact, and not change it.
Narration only Please pause the tutorial, make a copy of numbers.tex and open it.

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

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

Open align.tex Let me open align.tex
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.

Point to the equations These equations do not have numbers.
Remove the * from align We can put equation numbers by removing the star from the align star.
Remove the * from begin align and end align


Remove the star from both begin and end statements.

Forgetting it in the end statement is a common mistake.

Put * in end align statement Let’s see what happens if I forget to remove it from the end align statement.
Compile Let us compile.
Error message It gives an error message- begin align ended with align star.
Remove the * from end align Let us remove the star from end align also.

Let us abort typesetting and compile.

We now have equation numbers.

Write a statement that makes use of the number of the second equation. Let us now refer to the second equation in the running text.

Put the number 2 after the word equation.

Compile Compile.

We see number 2 in the running text.

Narration I will now show you how to remove the equation number of one equation.
Point to first equation Suppose that we don’t want a number for the first equation.
Put \nonumber at the end of first equation and compile Go to the end of the first equation, but before intertext, and put back slash nonumber.
Highlight \nonumber Please note that nonumber is one word.

Do not forget the back slash at the beginning.

Compile >>Point to 1st equation On compiling, the number disappears from the first equation.
Highlight the 2nd equation One consequence is that the second equation is now numbered as one.
Highlight equation 2 in the running text Unfortunately, the reference to the second equation has become wrong in the text.
Narration only Can we prevent such mistakes even if we have to add or remove equations?

Such a requirement occurs frequently while writing reports, theses, papers, etc.

Put \label{PID} It is possible to do this through the label statement.

We have seen this in a previous tutorial also.

Let me put slash label PID at the end of the second equation, but before end align.

Put \ref{PID} Replace 2 in the running text with slash ref PID as I do now.
Compile After compiling once, two question marks appear against the equation number.
Compile again On compiling twice, the question marks get replaced by the correct number.
Remove \nonumber Let us change the equation number once again by removing nonumber.
Compile twice. Compile twice to get correct answers.

Change PID to pid in ref command, but don’t compile


Put it back as PID in label command

Compile

The variable in the ref and label commands have to be identical.

Check what happens if you change PID in the ref command to lowercase.

Leave the PID in uppercase in the label command and compile.

Point to question mark We get question mark here because this lowercase pid is not defined.

I will put pid back in uppercase and compile.

Narration I will now show you how to take help from the Internet.
Delete all the text in the tex file Before that, I am going to delete everything in the tex file.

If you don’t like it, you can open a new file.

Narration only To do this part, you need access to Internet.

If you don’t have this access now, you may try this part later.

Go to Google page >> type LaTeX multiline in the search bar Let me go to a web browser.

Let me do a web search on the topic of LaTeX multiline.

Hover on stackexchange The very first hit is on stackexchange.

Let me click this “How to align...”.

Scroll down the page If you scroll down this page, you will see a question and several answers.

Most answers present a complete code.

Copy from top to bottom, not from bottom Let us copy the code that says 58.

This number may be different when you access this page.

Below this, the pdf output created by this code is shown.

Let me paste it on the tex file.

Compile Let us compile the tex file.

You can check the output in this pdf file to be identical to what we saw in stackexchange.

Please try all commands explained in this web page and understand them.
Remove the text between the begin and end document Next let me delete everything inside the document environment.

Let us now open the ltxprimer pdf file that we have provided with this tutorial.

You can practise this part even if you don’t have web access.

Scroll down the page >> Contents Let us scroll and go to Contents.
Click on Typesetting Mathematics Let us click “Typesetting Mathematics”.
Point to the examples. You can see many examples.
Go to page 87 Let us go to page 87.
Copy and paste the code Let us copy “cases code” and paste it within the document environment.
Compile On compiling it, we get the output given in ltxprimer.
Change equation* to align* >> Compile You may change equation* to align*, and compile.

We get identical results.

I suggest that you spend a minute in understanding this example.

I also suggest that you try more examples from ltxprimer.

This brings us to the end of this tutorial.
What did we learn slide

Press space

This page summarises what we learnt in this tutorial.

Please recall each of these commands.

This is your first assignment.

Please do a search on these commands over the web, in ltxprimer, etc.

Locate these examples and try them out.

More assignments slide I will give some more assignments.
Assignment 2


We compiled twice to get correct numbers.

Why should we compile twice?

Hint: we saw this in an earlier tutorial.

You can also locate an answer for this in ltxprimer.pdf file.

Search for Cross References.

Assignment 3 Try examples from Chapter 8 of ltxprimer pdf file we saw earlier.

Try to understand them.

Assignment 4 Try multiline examples from the Stackexchange web page we saw earlier.
About the ST slide

Press the Enter key

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 Space key

Space

Space

Space

Space 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 stackexchange at this address.

This is a great place to get answers on LaTeX.

General questions slide You may also have questions on our workshops, certificates, etc.

For this, get in touch with us at this email address.

Spoken Tutorial project is funded by MHRD, Government of India.
Thanks for joining.

Goodbye.

Contributors and Content Editors

Nancyvarkey, PoojaMoolya, Pravin1389