Contents
LaTeX in Instructor-authored sections
- Overview of features
- Inline/single-line equations
- Displaying multiline equations
- Fractions
- Matrices
- Calculus
LaTeX in Markdown (Instructor notes and Classic zyLabs)
- Overview
- Inline/single-line equations
- Displaying multiline equations
- Fractions
- Matrices
- Calculus
- Common mistakes
- Subscripts
- Strikeout
LaTeX in Instructor-authored sections
This subsection gives an overview of the LaTeX code that works within Instructor-authored sections. This included Advanced Labs.
These instructions will NOT apply to Instructor notes and Classic labs, as those use LaTeX inside of Markdown, so please navigate to the following subsection, LaTeX in Markdown (Instructor notes and Classic zyLabs).
Overview of features
- The following environments are supported by the zyBooks content creator:
- align - vertically aligns several equations
- cases - renders multiline equations with an extensible left curly brace, which can be used to display piece-wise defined functions.
- gather - displays consecutive equations with no alignment
- The following environments are NOT supported by the zyBooks content creator:
- multline
- flalign
- center
- tabular
- Special characters such as >, <, and & should be entered as \gt, \lt, and \& respectively.
- The TeX shorthand $...$ that declares inline code does not work.
- Automatic equation numbering is suppressed by default and cannot be enabled.
Inline/single-line equations
The LaTeX shorthand that declares inline expressions and equations is
\(...\)
Example:
This equation \(x^2-3x+4=0\) is inline.
The LaTeX shorthand that declares displayed equations (i.e. equations that are on separate lines outside of normal text) is
\[...\]
Example:
The equation \[x^2-3x+4=0\] has a break and is centered.
The equation
has a break and is centered.
Displaying multiline equations
Multiline equations are displayed using the align, gather, and cases environments.
Align
The align environment has a tabular structure with the symbol & used as a column separator. The default alignment is right, left, right, .... Using && overrides the default alignment. Lines are separated using \\.
Example:
\[\begin{align} x^2 -3x+4 &=0 \\ (x-1)(x-3)&=0 \\ x=1, x&=3 \end{align}\]
Example:
\[\begin{align}2(x+1) &= 8 &\text{}\\2x+2 &= 8 &&\text{Distribute 2 on the
left} \\2x&=6 && \text{Subtract 2 from both sides} \\ x&=3 && \text{Divide
both sides by 2}\end{align}\]
Example:
\[ \begin{align} \text{(1)} && \sin^2 \alpha + \cos^2 \alpha &= 1\\
\text{(2)} && 1 + \cot^2 \alpha &= \csc \alpha\\ \text{(3)} && \tan^2
\alpha + 1 &= \sec \alpha\\ \end{align} \]
Gather
The gather environment displays and centers each equation.
Example:
\[\begin{gather} y=mx+b \\ y-y_1=m(x-x_1) \\ Ax+By=C \end{gather}\]
Cases
The cases environment renders multiline equations with an extensible left curly brace. Columns are separated by the symbol & and lines are separated by \\.
Example:
\[f(x) = \begin{cases} x & \text{if } x \geq 0 \\ x &\text{if }x \lt 0\end{cases}\]
Fractions
The default style of mathematical operators and elements change depending on whether inline or displayed equation is used. Using the \displaystyle command before each element renders that element with the same style as a displayed equation.
Example:
\(\frac{3x^2}{\sin^2 x - 1}\)
Example:
\[\frac{3x^2}{\sin^2 x - 1}\]
Example:
\(\dfrac{3x^2}{\sin^2 x - 1}\)
Example:
\(\displaystyle\frac{3x^2}{\sin^2 x - 1}\)
If a smaller fraction is needed, \tfrac can be used.
Example:
\[\tfrac{x+2}{x-5}\]
This fraction
is centered but still in the smaller type set.
Matrices
The matrix environment renders an array. Columns are separated by the symbol & and lines are separated by \\.
Example:
\[\begin{matrix} -2i &6 \\ 0 & 2x-3 \end{matrix}\]
Other matrix environments are given in the table below.
Environment | Description | Example |
---|---|---|
matrix | plain | |
bmatrix | brackets | |
vmatrix | pipes | |
pmartix | parenthesis | |
Bmatrix | curly braces | |
Vmatrix | double pipes |
Calculus
Common symbols in calculus like integrals, limits, and sums are displayed using the code below.
Example:
\[\sum_{n=1}^{\infty} 2n \\ \lim_{x \rightarrow 0} x^2\\ \int_{2}^{5} (x^2 + 2x + 1)dx\]
Example:
\(\sum_{n=1}^{\infty} 2n \\ \lim_{x \rightarrow 0} x^2\\ \int_{2}^{5} (x^2 + 2x + 1)dx\)
Using the \limits command before each operator renders that operator with the same style as a displayed equation.
Example:
\(\sum\limits_{n=1}^{\infty}2n\\ \lim\limits_{x \rightarrow 0} x^2\\ \int\limits_{2}^{5} (x^2 + 2x + 1)dx \)
The \displaystyle command can also be used.
Example:
\(\displaystyle\sum_{n=1}^{\infty} 2n\\ \displaystyle \lim_{x \rightarrow 0} x^2\\ \displaystyle \int_{2}^{5} (x^2 + 2x + 1)dx\)
Other common symbols used in calculus are given in the table below.
LaTeX code | Output |
---|---|
\iint | |
\iint\limits_R | |
\iiiint | |
\int\dots\int | |
\oint |
LaTeX in Markdown (Instructor notes and Classic zyLabs)
The following instructions apply to Classic zyLab and instructor notes specifically. Please see our articles on How to create a new zyLab (Classic) and How to add custom instructor notes for more details.
Overview
The Classic zyLab and instructor notes editor uses Markdown, so you may need to escape the Markdown characters in order for the LaTeX to render properly.
For example, the traditional LaTeX formatting to write an in-line equation is,
\(...\)
However, to write an inline equation in LaTeX with Markdown, you would need to escape the backslashes.
For example, this code,
This is an equation \(x^2 + 1 = 10\)!
would render as,
Escaping the backslashes would render properly.
This is an equation \\(x^2 + 1 = 10\\)!
All the following examples will show the correct syntax with the escaped Markdown characters.
Inline/single-line equations
To declare in-line expressions,
\\(...)\\
Example:
This equation \\(x^2-3x+4=0\\) is inline.
To display equations (i.e. equations that are on separate lines outside of normal text) is
\\[...\\]
or
$$...$$
Example:
The equation \\[x^2-3x+4=0\\] has a break and is centered.
The equation $$x^2-3x+4=0$$ has a break and is centered.
Displaying multiline equations
Multiline equations are displayed using the align, gather, and case environments.
Align
The align environment has a tabular structure with the symbol & used as a column separator.
Lines are separated using \\\.
Example:
\\[\begin{align} x^2 -3x+4 &=0 \\\
(x-1)(x-3)&=0 \\\
x &= 1,3 \end{align}\\]
Example:
\\[\begin{align}2(x+1) &= 8 &\text{}\\\2x+2 &= 8 &&\text{Distribute 2 on the
left} \\\2x&=6 && \text{Subtract 2 from both sides} \\\ x&=3 && \text{Divide
both sides by 2}\end{align}\\]
Example:
\\[ \begin{align} \text{(1)} && \sin^2 \alpha + \cos^2 \alpha &= 1\\\
\text{(2)} && 1 + \cot^2 \alpha &= \csc \alpha\\\ \text{(3)} && \tan^2
\alpha + 1 &= \sec \alpha\\\ \end{align} \\]
Gather
The gather environment displays and centers each equation.
Example:
\\[\begin{gather} y=mx+b \\\ y-y\_1=m(x-x\_1) \\\ Ax+By=C \end{gather}\\]
Cases
The cases environment renders multiline equations with an extensible left curly brace. Columns are separated by the symbol & and lines are separated by \\.
Example:
\\[f(x) = \begin{cases} x & \text{if } x \geq 0 \\\ x &\text{if }x \lt 0\end{cases}\\\]
Fractions
The default style of mathematical operators and elements change depending on whether inline or displayed equation is used. Using the \displaystyle command before each element renders that element with the same style as a displayed equation.
Example:
\\(\frac{3x^2}{\sin^2 x - 1}\\)
Example:
This fraction, \\[\frac{3x^2}{\sin^2 x - 1}\\], is usi
Example:
This fraction, \\(\dfrac{3x^2}{\sin^2 x - 1}\\), is inline.
Example:
This fraction, \\(\displaystyle\frac{3x^2}{\sin^2 x - 1}\\), is using "\displaystyle".
If a smaller fraction is needed, \tfrac can be used.
Example:
This fraction \\[\tfrac{x+2}{x-5}\\] is centered but still in the smaller type set.
Matrices
The matrix environment renders an array. Columns are separated by the symbol & and lines are separated by \\\.
Example:
\\[\begin{matrix} -2i &6 \\\ 0 & 2x-3 \end{matrix}\\]
Other matrix environments are given in the table below.
Environment | Description | Example |
---|---|---|
matrix | plain | |
bmatrix | brackets | |
vmatrix | pipes | |
pmartix | parenthesis | |
Bmatrix | curly braces | |
Vmatrix | double pipes |
Calculus
Common symbols in calculus like integrals, limits, and sums are displayed using the code below.
Example:
\\[\sum\_{n=1}^{\infty} 2n \\\
\lim\_{x \rightarrow 0} x^2\\\
\int\_{2}^{5} (x^2 + 2x + 1)dx\\]
Example:
\\(\sum\_{n=1}^{\infty} 2n \\\
\lim\_{x \rightarrow 0} x^2\\\
\int\_{2}^{5} (x^2 + 2x + 1)dx\\)
Using the \limits command before each operator renders that operator with the same style as a displayed equation.
Example:
\\(\sum\limits\_{n=1}^{\infty}2n\\\
\lim\limits\_{x \rightarrow 0} x^2\\\
\int\limits\_{2}^{5} (x^2 + 2x + 1)dx \\)
The \displaystyle command can also be used.
Example:
\\(\displaystyle\sum\_{n=1}^{\infty} 2n\\)
...
Other common symbols used in calculus are given in the table below.
LaTeX code | LaTeX in Markdown example | Output |
---|---|---|
\iint |
$$\iint$$ |
|
\iint\limits_R |
$$\iint\limits\_R$$ |
|
\iiiint |
$$\iiiint$$ |
|
\int\dots\int |
$$\int\dots\int$$ |
|
\oint |
$$\oint$$ |
Common mistakes
Using underscores for subscripts
Another common Markdown character to look out for is the underscore. Recall that Markdown italicizes any text that is surrounded by underscores.
For example, here we are trying to render a LaTeX equation that uses subscripts. This code,
This equation \(x_1 - x_2\) is an example.
would render as,
If you look closely, you can see that the code surrounded by the underscores (1 - x) is actually italicized. To fix this, you can escape the underscores.
This equation \\(x_1 - x\_2\\) is an example.
This would be rendered as,
Strikeout
Recall in LaTeX that the command for strikeout is, \cancel.
Please note that you must require the \cancel package before using it or the strikeout may not render on the next page load.
Example:
$$\require{\cancel}\frac{a\bcancel{b}}{\bcancel{b}}=a$$