How do I change a separator in tabular just for one row in LaTeX? - 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}

Related

Long equation spread across the whole page in two column format

I use the strip environment for a long equation in a two-column page format, but the equation number appears at the edge of the first column and not after the equation ends.
\begin{strip}
\begin{equation}
f_{k+i,j} \left(
\bar{A}^{k+i+1}\hat{x}_{-1} +
\bar{A}^{i+1}\bar{B}_k \begin{bmatrix} \Tilde{y}_0 \\ \vdots \\ \Tilde{y}_{k-1} \end{bmatrix} +
\bar{B}_{i+1} \left(
\begin{bmatrix} {y}_k \\ CA\hat{x}_k \\ \vdots \\ CA^i\hat{x}_k \end{bmatrix}
+
\begin{bmatrix} M_s\delta_k \\ M_s\delta_{k+1} \\ \vdots \\ M_s\delta_{k+i} \end{bmatrix} \right) \right) \leq h_{k+i,j}
- \sqrt{f_{k+i,j}\Sigma_{\zeta_i}f_{k+i,j}^T}\Phi^{-1}\left(1 - \frac{\alpha}{s_{k+i}}\right)
- \max_{\eta \in \Gamma} f_{k+i,j}\bar{A}^{k+i+1}\eta
\end{equation}
\end{strip}

Showing entries of a vector one after another

Overflow Community! I'm working on a Latex Beamer - Document and I cant think of a nice looking solution for what I am planning to do.
So I have a vector, which entries I want to show one after another. But the right bracket is missing in the first steps when I'm using \pause in my equation, which looks quite ugly. So what I want is both brackets to be visible, while the vectors entries are not. Do you guys have a solution for this?
\documentclass[mathserif, 10pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,bm,amsthm,graphicx,skmath}
\begin{document}
\begin{frame}
\frametitle{Function $g$}
\[
g(x)=\begin{pmatrix}
g_1(x)\\ \vdots \\ g_n(x) \\ g_{n+1}(x) \\ \vdots \\ g_{2n}(x) \\ g_{2n+1}(x)\\ \vdots \\ g_{3n}(x)
\end{pmatrix}
\pause = \begin{pmatrix}
x_1^2 + x_{n+1}^2 - 1 \\ \vdots \\ x_n^2 + x_{2n}^2 - 1\\ \pause -x_{2n+1}\\ \vdots \\ -x_{3n} \\ \pause x_{2n+1}-L \\ \vdots \\x_{3n}-L
\end{pmatrix}
\]
\end{frame}
\end{document}
\pause is a very crude command, for more fine control you can use commands like \visible<...>{...}.
Please note that you don't need graphicx, amsmath or amsthm with beamer and that the mathserif option is obsolete. This should have caused a warning with a detailed description how this option should be replaced, please don't ignore such warnings.
\documentclass[10pt]{beamer}
\usepackage[utf8]{inputenc}
\usefonttheme[onlymath]{serif}
\usepackage{amsmath,bm,amsthm,
%graphicx,
skmath}
\begin{document}
\begin{frame}
\frametitle{Function $g$}
\[
g(x)=\begin{pmatrix}
g_1(x)\\ \vdots \\ g_n(x) \\ g_{n+1}(x) \\ \vdots \\ g_{2n}(x) \\ g_{2n+1}(x)\\ \vdots \\ g_{3n}(x)
\end{pmatrix}
\visible<2->{ = \begin{pmatrix}
x_1^2 + x_{n+1}^2 - 1 \\ \vdots \\ x_n^2 + x_{2n}^2 - 1\\ \visible<3->{ -x_{2n+1}}\\ \visible<3->{\vdots} \\ \visible<3->{-x_{3n}} \\ \visible<4->{x_{2n+1}-L} \\ \visible<4->{\vdots} \\\visible<4->{x_{3n}-L}
\end{pmatrix}}
\]
\end{frame}
\end{document}
You'll want Beamer's \uncover command, which hides its argument but still makes it take up space:
\[
g(x)=\begin{pmatrix}
g_1(x)\\ \vdots \\ g_n(x) \\ g_{n+1}(x) \\ \vdots \\ g_{2n}(x) \\ g_{2n+1}(x)\\ \vdots \\ g_{3n}(x)
\end{pmatrix}
\pause = \begin{pmatrix}
x_1^2 + x_{n+1}^2 - 1 \\ \vdots \\ x_n^2 + x_{2n}^2 - 1\\ \uncover<3->{-x_{2n+1} \\ \vdots \\ -x_{3n}} \\ \uncover<4->{x_{2n+1}-L \\ \vdots \\x_{3n}-L}
\end{pmatrix}
\]
The bit in the angle brackets (e.g. <3->) indicates that the argument should be uncovered (visible) on frames 3 onwards.
You can also use \visible instead, the difference being:
The \visible command does nearly the same as \uncover. However one difference occurs if the command \setbeamercovered{transparent} has been used to make covered text “transparent” instead, \visible still makes the text completely “invisible” on non-specified slides.

Trying to understand how Pandoc converts from Markdown to Latex

I apologize if this is a repeat.
I have a Markdown file test.md which has two latex math mode parts:
First latex block (in .md file):
\begin{flalign}
P(1<X) &= \int_{1}^{\infty} f(x) dx \nonumber \\
&= \int_{1}^{4} 0 dx + \int_{4}^{\infty} e^{-(x-4)} dx \nonumber \\
\boldsymbol{P(1<X)} &= \boldsymbol{1} \nonumber
\end{flalign}
Second latex block (in .md file):
\begin{flalign}
Expected \; Revenue &= 2.5 \cdot non-passenger \; vehicles + 1.0 \cdot passenger \; vehicles \nonumber \\
&= \$(2.5 \cdot (25 - E(X)) + 1.0 \cdot E(X)) \nonumber \\
&= \$(62.5 - 1.5(E(X))) \nonumber \\
&= \$(62.5 - 1.5 \cdot 15) \nonumber \\
\boldsymbol{Expected \; Revenue} &= \boldsymbol{\$40} \nonumber
\end{flalign}
When I run the following command:
pandoc -f markdown -t latex test.md -s -o test.tex
I get the output as test.tex where the above two blocks are rendered as:
First latex block (in .tex file):
\textbackslash{}begin\{flalign\} P(1\textless{}X) \&=
\int\emph{\{1\}\^{}\{\infty\} f(x) dx \nonumber \textbackslash{} \&=
\int}\{1\}\^{}\{4\} 0 dx + \int\_\{4\}\^{}\{\infty\} e\^{}\{-(x-4)\} dx
\nonumber \textbackslash{} \boldsymbol{P(1<X)} \&= \boldsymbol{1}
\nonumber \textbackslash{}end\{flalign\}
Second latex block (in .tex file):
\begin{flalign}
Expected \; Revenue &= 2.5 \cdot non-passenger \; vehicles + 1.0 \cdot passenger \; vehicles \nonumber \\
&= \$(2.5 \cdot (25 - E(X)) + 1.0 \cdot E(X)) \nonumber \\
&= \$(62.5 - 1.5(E(X))) \nonumber \\
&= \$(62.5 - 1.5 \cdot 15) \nonumber \\
\boldsymbol{Expected \; Revenue} &= \boldsymbol{\$40} \nonumber
\end{flalign}
I am not sure how this happened. I am using:
OS: Windows 10
Editor: Visual Studio Code 1.28.1
Pandoc Version: 2.2.3.2
I though maybe it is because of the line endings being different in Windows so I changed the Line Endings from CLRF to LF and vice-versa but this didn't effect the output.
I would like to be able to say with certain surety as to how the conversion will happen as this is confusing to me.
I have also uploaded the files in case it is an issue of encoding of chars.
Pandoc's LaTeX parser is not 100% perfect, so for complicated cases like this, you should use generic-raw-attributes in your markdown:
```{=latex}
\begin{flalign}
Expected \; Revenue &= 2.5 \cdot non-passenger \; vehicles + 1.0 \cdot passenger \; vehicles \nonumber \\
&= \$(2.5 \cdot (25 - E(X)) + 1.0 \cdot E(X)) \nonumber \\
&= \$(62.5 - 1.5(E(X))) \nonumber \\
&= \$(62.5 - 1.5 \cdot 15) \nonumber \\
\boldsymbol{Expected \; Revenue} &= \boldsymbol{\$40} \nonumber
\end{flalign}
```

\right) doesn't work on LaTeX multiline equation

I'm writing an equation on LaTeX and when I want to close the formula with \right) it doesn't work. I'll post my code here to see if anyone can help me:
\begin{equation*}
\begin{split}
&\bigtriangledown h=\left( \frac{1}{2}\cdot \cos \left(\frac{1}{2}\cdot x\right) \cdot \cos(y) + \cos(x) \cdot \cos(y),
\frac{-1}{2} \cdot \cos\left(\cos \left(\frac{1}{2}\cdot y\right)\right)\cdot \\ &\sin\left(\frac{1}{2} \cdot y\right) - \sin\left(\frac{1}{2}\cdot x\right) \cdot \sin(y) - \sin(x) \cdot \sin(y) \right)
\end{split}
\end{equation*}
This is happening because the paired \left( and \right) cannot be broken over different lines in multi-line environments. So one cannot start \left( on one line of a multi-line equation and pair it with \right) on another line.
You can trick it, though, by giving it a fake matching paren: \left( \right. The period . matches any kind of bracket. Now it will accept this on its own, and simply produce a left parenthesis. You have to remember to do the same with the right paren, and you have to adjust sizes yourself since the automatic resizing won't work. I find that for your example you may want \Bigg( \Bigg. paired with \Bigg. \Bigg)
\begin{equation*}
\begin{split}
& \bigtriangledown h=
\Bigg( \Bigg.
\frac{1}{2}\cdot \cos \left(\frac{1}{2}\cdot x\right) \cdot \cos(y)
+ \cos(x) \cdot \cos(y),
\frac{-1}{2} \cdot \cos\left(\cos \left(\frac{1}{2}\cdot y\right)\right)\cdot \\
& \sin\left(\frac{1}{2} \cdot y\right)
- \sin\left(\frac{1}{2}\cdot x\right) \cdot \sin(y)
- \sin(x) \cdot \sin(y)
\Bigg. \Bigg)
\end{split}
\end{equation*}
This now works, but I'd move the alignment point to after = so the next line is indented (or, rather, after the opening parenthesis). However, I'd first suggest to look into yet other options availed by amsmath package.
Since you do not want numbering any way, and may want to align precisely, one option that gives more control is the align environment. With your equations, rearranged a little
\usepackage{amsmath}
\begin{align*}
\bigtriangledown h = \Bigg( \Bigg. &
\frac{1}{2}\cdot \cos \left(\frac{1}{2}\cdot x\right) \cdot \cos(y)
+ \cos(x) \cdot \cos(y), \\
& -\frac{1}{2} \cdot \cos\left(\cos \left(\frac{1}{2}\cdot y\right)\right)\cdot
\sin\left(\frac{1}{2} \cdot y\right) \\
& - \sin\left(\frac{1}{2}\cdot x\right) \cdot \sin(y)
- \sin(x) \cdot \sin(y) \Bigg. \Bigg)
\end{align*}
There is a number of other environments for multi-line equations, to suit different cases. Here is a clear page on Aligning Equations and here is the official amsmath User's Guide (pdf).
This is the image of both examples above, first the one using align, wrapped together with
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\begin{document}
% ... example using align environment, a line of text, example with split
\end{document}
I kept the second example as in the OP but consider aligning after the = sign, as mentioned.

LaTex: how does the include-command work?

I supposed the include-command copy-pastes code in the compilation, it is wrong because the code stopped working. Please, see the middle part in the code. I only copy-pasted the code to the file and added the include-command.
$ cat results/frames.tex
10.31 & 8.50 & 7.40 \\
10.34 & 8.53 & 7.81 \\
8.22 & 8.62 & 7.78 \\
10.16 & 8.53 & 7.44 \\
10.41 & 8.38 & 7.63 \\
10.38 & 8.57 & 8.03 \\
10.13 & 8.66 & 7.41 \\
8.50 & 8.60 & 7.15 \\
10.41 & 8.63 & 7.21 \\
8.53 & 8.53 & 7.12 \\
Latex code, see the middle part
\begin{table}
\begin{tabular}{ | l | m | r |}
\hline
$t$ / s & $d_{1}$ / s & $d_{2}$ / s \\
$\Delta h = 0,01 s$ & $\Delta d = 0,01 s$ & $\Delta d = 0,01 s$ \\
\hline
% I JUST COPIED THE CODE from here to the file, included.
% It stopped working, why?
\include{results/frames.tex}
\hline
$\pi (\frac{d_{1}}{2} - \frac{d_{2}}{2})$ & $2 \pi R h$ & $2 \pi r h$ \\
\hline
\end{tabular}
\end{table}
Use \input instead of \include, that will work.
\include additionally performs a \clearpage command which will not work in the context of a table.
Try with \input, \include is old and very limited..

Resources