News

LaTeX Questions Answered: Where Can I Learn About LaTeX?

The following is an excerpt from the chapter LaTeX Questions Answered in Pressbooks Guide: A reference for open textbook authors using Pressbooks by Lauri M. Aesoph

Where can I learn about LaTeX?

What is LaTeX?

LaTeX is a markup language and typesetting system commonly used in mathematical and scientific writing. It can be used to create documents from scratch or display equations in a web browser with the help of plugins, as is the case in Pressbooks.

Below is an example of what LaTeX can look like. This is a simple example, but LaTeX can be used to write much more complex expressions.

Use the formula V=πr2h to calculate the volume of a cylinder.

How do I write a LaTeX expression in Pressbooks?

Use the delimiters [latex]…[/latex] to mark the boundaries between LaTeX and regular text. This is the simplest and best way in Pressbooks to write LaTeX expressions that will be rendered by MathJax. These shortcodes can be used to write in-line LaTeX expressions (i.e., in the middle of regular text) or to left-align a LaTeX expression written on its own line.

If you are using the British Columbia/Yukon Open Authoring PlatformMathJax will be activated and ready to render whatever you write between these shortcodes into clean, readable mathematical expressions.

For example, we all know that a2+b2=c2 is the Pythagorean theorem. Here it is again, on its own line and centred using HTML:

a2+b2=c2

To see how to write this expression, follow the instructions in How do I view an expression as it appears in LaTeX markup?

A Second Method

Assuming you’re rendering your LaTeX using MathJax, there are technically two notation methods for writing LaTeX. You can either surround your LaTeX markup with [latex]…[/latex] or $$…$$. However, this second method comes with a catch.

$$…$$ notation centres a LaTeX expression and puts it on its own line, even if it is used in the middle of a sentence.

For example, the formula:

A=1/2bh

can be used to calculate the area of a triangle.

In editor view, this looks like For example, the formula $$A=\dfrac{1}{2}bh$$ can be used to calculate the area of a triangle.

This is great, except for one major caveat: LaTeX expressions written using $$…$$ delimiters do not render in PDFs. If you use this notation in the webbook version of your book in Pressbooks, your expression will render and appear as expected. But if you then export the webbook as a PDF, your expression will appear in the PDF as the original LaTeX markup, which is not particularly pretty or human readable.

Therefore, we recommend using [latex]…[/latex] for all LaTeX expressions if there’s a possibility that you will export your webbook to other formats. If you would like your expression to appear centred and on its own line, simply write it on its own line and centre it using Shift + Alt + C or the “Align centre” button on the visual editor toolbar.

Which LaTeX commands work in Pressbooks?

Only those LaTeX commands that are supported by MathJax will work in the BCcampus instances of Pressbooks, as well as any other Pressbooks instances that rely on MathJax to render LaTeX.

See the Supported TeX/LaTeX commands page in MathJax’s documentation to view a full list of LaTeX commands that will work in Pressbooks.


The featured image for this post (viewable in the BCcampus News section at the bottom of our homepage) is by Deepak Gautam from Pexels

Share This