Latex error missing { inserted. \end{align}? - alignment

I get this error when trying to compile the following code. It says "error missing { inserted. \end{align}".
\begin{align}
$$
d_r \quad &= \quad k_r, \\
d_{r-1} \quad &= \quad k_r + k_{r-1}, \\
d_{r-2} \quad &= \quad k_r + k_{r-1} + k_{r-2}.
$$
\end{align}
The output result I get is the one I want, I mean everything's aligned and nice but I keep getting the error. What is the problem here? Thanks in advance!

Related

How do I change a separator in tabular just for one row in LaTeX?

I'd like to change a column separator just for one row in my tabular.
For now, the = is set up as a separator between columns, for the last row I would like to change it for a \vdots.
Thanks a lot.
EDIT:
I did what #achim suggested and it works, but still is there any ''nicer'' solution?
here is a proposition to use the align environment to align the equation you need and write all the math in one same environment rather than in a tabular.
It only require the package amsmath in the beginning of the file.
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\begin{document}
Proposal
\begin{align*}
\text{vychozi tvar} & ~ & y' + p(x) y &= q(x) \\ \hline
\text{reseni} & ~ & y' + p(x)y &= q(x) / \cdot e^{\int p(x)\, \dx} \\
& ~ & \left(y\cdot e^{\int p(x)\, \dx}\right) &=
q(x) \cdot e^{\int p(x)\, \dx} / \text{integrace} \\
& ~ & y\cdot e^{\int p(x)\, \dx} &= \int q(x) \cdot e^{\int p(x)\, \dx}\, \dx \\
& ~ & ~ &\vdots \\
\end{align}
\end{document}
The alignement is made with & sign and you can specify if it is = after or \vdots. You can still use text in this environment, juste use \text{lorem ipsum}.
This environment can number the line, juste remove * in \begin{align*}.
I tried to copy the bit of code you provided in picture, in future, include it in your question so we can solve issue quickly. Sorry if I made typos in my copy, I hope this suite your case.
EDIT : You may want to add the vertical line between the left text and your equations...here is a second solution, however I can't manage to align the equation all along
\begin{tabular}{l|l}
vychozi tvar & \parbox{0.3\linewidth}{%
\begin{align*}
y' + p(x) y &= q(x) \\
\end{align*}}\\ \hline
reseni & \parbox{0.3\linewidth}{%
\begin{align*}
y' + p(x)y = q(x) / \cdot e^{\int p(x)\, \dx} \\
\end{align*}} \\
~ & \parbox{0.3\linewidth}{
\begin{align*}
\left(y\cdot e^{\int p(x)\, \dx}\right) &=
q(x) \cdot e^{\int p(x)\, \dx} / \text{integrace} \\
y\cdot e^{\int p(x)\, \dx} &= \int q(x) \cdot e^{\int p(x)\, \dx}\, \dx \\
~ &\vdots & ~ \\
\end{align*}} \\
\end{tabular}

how to write inline matrix in Latex

\begin{pmatrix} 2 \\ 4 \\ -2 \end{pmatrix}
This is 3*1 vector matrix and i want to write another matrix or x and y s beside that one.
Is there any method to write matrix inline ?
Are you using in-line delimiters around the math? E.g.,
$\begin{pmatrix} 2 \\ 4 \\ -2 \end{pmatrix}$
If you put another matrix inside these delimiters, they will be put in-line next to it. For instance, see this live example:
<script>
MathJax = {
tex: {inlineMath: [['$','$']]}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/tex-chtml.js" id="MathJax-script"></script>
This math is in line, $
\begin{pmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{pmatrix}
\begin{pmatrix} 2\\ 4\\ -2 \end{pmatrix}
$, with text following it.
Simply put your code inside two dollar signs ($) and it's done.
$ \begin{pmatrix} 2 \\ 4 \\ -2 \end{pmatrix} $
Note that if you put double dollar signs ($$) it will write the matrix in a new line and then continues the rest of the sentence in the line after that.
$$ \begin{pmatrix} 2 \\ 4 \\ -2 \end{pmatrix} $$

How to place a \figure*\minipage\eqnarray at the bottom of the SAME PAGE

I have a big equation that must be placed at the bottom of the page in a two columns paper. The call of the equation is at the end of the first column of a given page, but no matter what place holder I set([h!],[ht],etc), the equation goes to the next page. When I use [H] the equation dont even appear in the document.
I am using...
\documentclass[journal]{IEEEtran}
...
\usepackage{dblfloatfix}
...
The rotational torque that each motor generates is based on the signal compositions with the servomotor tilting angles. Thus, considering $ \dl = l \frac {\sqrt {2}} {2} $ and the right hand rule, resultant propulsion forces and torques on the $ \Fb $ are presented in Equation (\ref{eq1:gen_forces_torquesa}), suppressing the term $ (t) $:
\begin{figure*}[h!]
\begin{minipage}{.6\textwidth}
\begin{eqnarray} \label{eq1:gen_forces_torquesa}
\bm{\tau^b_p} &=&
\left(\begin{array}{cccccc}
X_{p}^{b} & Y_{p}^{b} & Z_{p}^{b} & L_{p}^{b} & M_{p}^{b} & N_{p}^{b}
\end{array}
\right)^T = \nonumber \\
&=&
\left(\begin{array}{c}
k_1\delta_1s(\gamma_1) + k_1\delta_2s(\gamma_2) + k_1\delta_3s(\gamma_3) + k_1\delta_4s(\gamma_4) \\
0 \\
-k_1\delta_1c(\gamma_1) - k_1\delta_2c(\gamma_2) - k_1\delta_3c(\gamma_3) - k_1\delta_4c(\gamma_4) \\
(-k_1\dl c(\gamma_1) - k_2s(\gamma_1))\delta_1 + (k_1\dl c(\gamma_2) - k_2s(\gamma_2))\delta_2 + (k_1\dl c(\gamma_3) + k_2s(\gamma_3))\delta_3 + (-k_1\dl c(\gamma_4) + k_2s(\gamma_4))\delta_4 \\
A_2 \\
A_3
\end{array}
\right) \nonumber \\
\end{eqnarray}
\end{minipage}
\end{figure*}
It always helps to have a complete minimal example.
It might be worth trying [b] instead. Perhaps also try inserting \newpage after the figure.

Latex Equation and bmatrix

I'm trying to use official equation, and it's giving me some trouble. I have this equation of a simple matrix operation, and LaTeX isn't liking it. What's wrong with this statement?
\begin{equation}
$M=\begin{bmatrix}
V_{1,1} & . & . & V_{1,n}\\
. & . & & \\
. & &. & \\
V_{m,1}& & & V_{m,n}
\end{bmatrix}$
\end{equation}
The error is:
! Display math should end with $$.
M
l.186 $M
=\begin{bmatrix}
? )
Delete the two dollar signs:
\begin{equation}
M=\begin{bmatrix}
V_{1,1} & . & . & V_{1,n}\\
. & . & & \\
. & &. & \\
V_{m,1}& & & V_{m,n}
\end{bmatrix}
\end{equation}
Removing the two $s, you have no more error.
Then, you may want to use the commands \cdots, \vdots, \ddots available from LaTeX (package amsmath is not even necessary for these three, while it is required for environment bmatrix):
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
M=\begin{bmatrix}
V_{1,1} & \cdots & V_{1,n}\\
\vdots & \ddots & \vdots\\
V_{m,1} & \cdots & V_{m,n}
\end{bmatrix}
\end{equation}
\end{document}
produces
(numbered equation). Notice how this is a 3-x-3 matrix, not 4-x-4.

LaTeX: Numbering only last line of multi-line equation in \align

I want to number and make a reference to just the last line of a multi-line equation in \align. Here is an example:
\begin{align}
z_1^2 &= \left( 2 e^{i \frac{\pi}{3}} \right) \left( 2 e^{i \frac{\pi}{3}} \right)\\
&= 4 e^{i \frac{2 \pi}{3}}
\end{align}
I only want to number the &= 4 e^{i \frac{2 \pi}{3}} part, rather than both lines of the \align. How do I do this?
From the amsmath documentatiom (amsldoc.pdf):
You can suppress the number on any
particular line by putting \notag
before the \\;
So your equation should look like this (some bits removed from your equation to make it shorter):
\begin{align}
z_1^2 &= \left( ... \right) \left( ... \right)\notag\\
&= 4 e^{i \frac{2 \pi}{3}}
\end{align}

Resources