GeoGebra Tutorial 13 – How to use Latex in GeoGebra

This is the 13th GeoGebra Tutorial in the GeoGebra Tutorial Series and in this post, we learn how to use Latex in GeoGebra. If this is your first time to use GeoGebra, you might want to read the GeoGebra Essentials Series first.

In my previous posts, we have discussed how to use Latex in writing mathematical equations in blogs and websites,  and we also have learned the most commonly used Latex commands.

For those who are new to  Latex, it is a typesetting program capable of generating mathematical expressions which can be embedded in blogs, forums and websites.  For example, the quadratic formula below is written using Latex code

x = \displaystyle\frac{-b \pm \sqrt{b^2-4ac}}{2a}.

Fortunately, many mathematics software nowadays are compatible with Latex typesetting. In this tutorial, we learn how to use Latex in GeoGebra.  If you already know how to code Latex, then this will be very easy for you. However, if this is your first time to use Latex, you may want to read an introduction about it.

In GeoGebra, we can only code Latex using the Insert Text tool. For example, we write the of the famous Pythagorean theorem equation c2 = a2 + b2, we need to use Latex code because GeoGebra is not capable of creating superscripts, except for equations or expressions placed in the Input bar. If we will not use Latex, our equation will appear like c2 = a2 + b2 or we can use c^2 = a^2 + b^2.  But suppose the  equation that we type is more complicated – such as the quadratic formula – it is impossible for us to write it without confusing the reader.

Follow the instructions below on how to use the Insert Text tool to generate Latex code. If you want to follow the tutorial step-by-step while reading, you can open the GeoGebra window here.

Instructions

1.)    To use the text tool, select the Insert Text tool and click the part of the Graphics view where you want to place the text.  This will display the Text dialog box.

2.)    In the Text dialog box, type the code c^2 = a^2 + b^2 in the Edit box and then be sure that the Latex formula check box is checked. The ^ is the code used for exponentiation. The Preview window shows how your text will be displayed.

3.)    Press the OK button when finished. Your text should look like the one shown in Figure 3.

To combine text and mathematical expressions coded in Latex, we have to separate the text and the mathematical formula. To do this, we have to enclose the mathematical expression with dollar signs. For example, if we want to write

The hypotenuse of a right triangle with sides a and b is equal to \sqrt{a^2 + b^2}

we have to type

The hypotenuse of a right triangle with sides $a$ and $b$ is equal to $\sqrt{a^2 + b^2}$

The GeoGebra output of the code written above is shown below.

Shown below are some of the most common symbols that are used in GeoGebra.

LaTeX input Result
a \cdot b a \cdot b
\frac{a}{b} \frac{a}{b}
\sqrt{x} \sqrt{x}
\sqrt[n]{x} \sqrt[n]{x}
\vec{v} \vec{v}
\overline{AB} \overline{AB}
x^{2} x^2
a_{1} a_{1}
\sin\alpha + \cos\beta \sin \alpha + \cos \beta
\int_{a}^{b} x dx \int_{a}^{b}xdx
\sum_{i=1}^{n} i^2 \sum_{i=1}^{n}i^2

If you want to practice other latex command download the list of latex symbols or comprehensive list of latex symbols.

Latex Tutorial: Commonly Used Latex Commands

INTRODUCTION

In my previous latex post, we have seen that Latex is capable of displaying complex mathematical expressions in blogs and forums. In this post, we will discuss the very basics Latex – the most commonly used symbols in high school mathematics and how to code them.

Almost all Latex commands or codes begin with the \ symbol. For example, we want to write a fraction, we must use the \frac command. If we want to use Latex in a WordPress blog, we should enclose it with two dollar signs (see Figure 2) with the word “latex” after the first dollar sign. The dollar signs and the word “latex” is not a latex command, but it tells WordPress (or other applications) that the enclosed text is a mathematical expression and should be displayed in Latex form.  Blogs and forums have different ways of embedding Latex commands (see my previous latex blog for further explanation), so you must know how they work.  In the following discussion, we will use the WordPress format.

If we want to copy the text writtenbelow (without the drawing, of course), we can use a combination of text and Latex in writing the solution.

Figure 1 – A forum post embedded with Latex

The solution was written as follows:

Figure 2 – The Latex code of the text in Figure 1

You should notice that the only latex command above is the \rightarrow command, but the equations are all written in Latex. This is because most of the time, it is advisable to write entire mathematical expressions in Latex to make it look better in web pages.

You should also be careful about the spaces between in your latex code. No spaces before and after the dollar sign, and 1 space after the word “latex”.

BASIC COMMANDS

Below are the basic commands commonly used in high school mathematics. If you want to learn more about the other symbols, a list of symbols can be viewed here and a comprehensive list can be viewed here.

Exponents and Subscripts

In Latex, the symbol ^ is used for exponents and the symbol _ is used for subscript. The {} symbol is used for grouping.

Expression Command Notes
2^3 2^3
2^{10} 2^{10} Note how {} is used. 2^10 will yield
p_k p_k
x^{3}_1 x^{3}_1
2^{a_k} 2^{a_k}
t_{n - 1} t_{n – 1} Try omitting the {} and see what happens.
c^2 = a^2 + b^2 c^2 = a^2 + b^2

 

Fractions

The command \frac is used to type fractions in Latex. The syntax is \frac{numerator}{denominator}.

Expression Command Notes
\frac{2}{3} \frac{2}{3}
\frac{3}{x + 5} \frac{3}{x + 5}
\frac{5}{x + \frac{1}{x}} \frac{5}{x + \frac{1}{x}} Notice that enclosed by the blue  braces are the numerator and denominator of a fraction in the denominator, there is another fraction.

 

Radicals

Radicals are written using the the \sqrt{expression} command. If the index, however, is greater than 2, the syntax is \sqrt[index]{expression}. (See examples 4 and 5}

Expression Command Notes
\sqrt{5} \sqrt{5}
\sqrt{a + b} \sqrt{a + b}
\sqrt{a + \frac{1}{a}} \sqrt{a + \frac{1}{a}}
\sqrt[3]{x + 3} \sqrt[3]{x + 3} You can write the index of the radical before the radicand expression.
\sqrt[5]{(32)^2} \sqrt[5]{(32)^2}

Geometry

Expression Command Notes
\overline{AB} \bot \overline{CD} \overline{AB} \bot \overline{CD} \botis the symbol for perpendicular
\angle {ABC} \cong \angle {PQR} \angle {ABC} \cong \angle {PQR}
\Delta{PQR} \approx \Delta{XYZ} \Delta{PQR} \approx \Delta{XYZ} Delta, the fourth letter of the Greek alphabet, is the symbol for triangle

 

With the Latex commands you already know, you will be surprised that you can already code a lot of expressions. Now try coding the quadratic formula. The code form \pm (plus-minus) is \pm.

The fraction \frac{3}{x+5} above is somewhat small. If you want it to appear in its full size, just add the \displastyle command before the \frac command and do not leave any white spaces. The command

\displaystyle\frac{3}{x+5}

will display \displaystyle\frac{3}{x+5}.

GOING FURTHER

You can do a lot more things using Latex. You can create documents, articles, create cross references among your documents and so on.  In fact, many books and ebooks nowadays are coded in Latex. In creating documents, however, we will need a Latex editor and a compiler.  I am planning to make a tutorial on how to make Latex documents using a Latex editor (not very soon though), so you may want to subscribe to my blog for later updates if you are interested.

Mr. Kogler has also a latex tutorial for  for advanced users here.

Note: If you want to test some of the latex commands, feel free to use the comment box.

Latex Tutorial: How to embed Latex in blogs and forums

What is Latex really?

Latex is a typesetting program which is now considered as a standard in mathematical writing.  It works just like MathType and Equation Editor, but has a lot more functionalities.  Equation Editor is just part of a word processor, but Latex is capable of creating an entire document, and mostly in pdf, dvi or postscript format. The other advantages of Latex are discussed by Robert Talbert in his blog Five reasons you should use latex and five tips for teaching it.  Openwetware.org also discusses the advantages of Latex over Microsoft Word.

Latex, however, is quite different because you have to code the  mathematical expressions and equations instead of writing them.

If you can see web pages with complicated equations or expressions, then it has to be Latex because most web pages do not support writing of mathematical expressions like word processors.

With Latex, equations like

x = \displaystyle\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

can be easily written in web pages and blogs. In fact, the quadratic formula  you see above is coded with Latex. To see the code, place the mouse pointer on the code and let it rest for about two seconds.

If you are familiar with HTML, it works just like it: its code is different from its output. If you want to write a fraction, for instance, the source code you have to type is \frac{a}{b} where a is the numerator and b is the denominator. This means, that if you want to write \frac{1}{2}, then you have to write \frac{1}{2}. Several examples of Latex source codes and their outputs are shown below. Do not be intimidated with the codes because in the next tutorial, I am going to discuss them slowly and step-by-step.

Latex Source Code Output
\sqrt{x} = 5 \sqrt{x} = 5
A = \frac{(b_1 + b_2)h}{2} A =\displaystyle \frac{(b_1 + b_2)h}{2}
c^2 = a^2 + b^2 c^2 = a^2 + b^2
d = \sqrt{(y_2 – y_1)^2 + (x_2-x_1)^2} d = \sqrt{(y_2 - y_1)^2 + (x_2-x_1)^2}
x = \frac{-b \pm \sqrt{b^2 – 4ac}}{2a} x =\displaystyle\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
1 + 2 + 3 + \ldots + n = \sum_{i=1}^{n} i = \frac{n(n+1)}{2} 1 + 2 + 3 + \ldots + n = \sum_{i=1}^{n} i = \displaystyle\frac{n(n+1)}{2}
Embedding Latex in Blogs, Forums and Web Pages

Latex  can be embedded in web pages, forums and blogs.  Note that not all forums or blogs are capable of embedding Latex, so you have to know if your service provider is compatible with Latex.   For instance, the Art of Problem Solving forum supports Latex while Ask Dr. Math does not.

Most forums or blogs let you embed Latex by placing dollar signs on both sides of the Latex code as shown below.  Suppose you want to write the following sentence:

For any triangle with side lengths a,b and hypotenuse c, then c^2 = a^2 + b^2.

If you are in Art of Problem Solving Forum, then you have to write it in the following format:

For any right triangle with side $a, b$ and hypotenuse $c$, then $c^2 = a^2 + b^2$.

Red-colored texts shown above are Latex codes.

Also, not all blogs or forums follow the same format. WordPress, for example, places the word latex after the first dollar sign before typing the code, and Moodle places two dollar signs at each side of the latex code. Notice below that the format of embedding changes depending on the service provider or website, but the latex code is always the same.

WordPress Code

For any right triangle with side $latex a, b$ and hypotenuse , then $latex c^2 = a^2 + b^2$.

Moodle Code

For any right triangle with side $$a, b$$ and hypotenuse $$c$$, then $$c^2 = a^2 + b^2$$.

In my next Latex blog, we will learn the basics of coding Latex.

Related Posts Plugin for WordPress, Blogger...