I want my document like this
(system of equations in the same line with text) not like this
Can anyone help me please? Here is my code for the second picture:
\hspace{2ex} Theo hệ thức Viète, ta có:
$$\begin{cases}
x_1 + x_2 = 2(m-1)\\
x_1 x_2 = -3-m
\end{cases} $$
There are two ways of typesetting mathematical equations in LaTeX, namely text style and display style. You are trying to write an in-line equation which is text style but the syntax $$<some equation>$$ is used for display style. The syntax for text style is $<some equation>$. So your code should be
\hspace{2ex} Theo hệ thức Viète, ta có:
$\begin{cases}
x_1 + x_2 = 2(m-1)\\
x_1 x_2 = -3-m
\end{cases}$
MWE:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\hspace{2ex} Theo hệ thức Viète, ta có:
$\begin{cases}
x_1 + x_2 = 2(m-1)\\
x_1 x_2 = -3-m
\end{cases}$
\end{document}
Output:
Note: You should use \[<some equation>\] instead of $$<some equation>$$ for display style. You may find the reason here.
I want the variables and signs aligned in a set of equations.
Desired output:
What I am trying in Mathjax:
\[
\begin{align}
2&x_1 - x_2 &+ 1.5&x_3 &= 8 \\
&x_1 &- 4&x_3 &= -1
\end{align}
\]
What I got:
So, what do I have to do to have the same alignment as in the "desired output" image?
There are a number of ways to achieve this. Below I use an array (with appropriate stretch and spacing), alignat and align coupled with eqparbox for measuring similarly-tagged boxes (this latter approach requires two compilations with every change in the largest element associated with every <tag>):
\documentclass{article}
\usepackage{amsmath,eqparbox}
%\usepackage{xparse}% If you have LaTeX2e < 2020-10-01
% https://tex.stackexchange.com/a/34412/5764
\makeatletter
% \eqmathbox[<tag>][<align>]{<math>}
\NewDocumentCommand{\eqmathbox}{o O{c} m}{%
\IfValueTF{#1}
{\def\eqmathbox###1##2{\eqmakebox[#1][#2]{$##1##2$}}}
{\def\eqmathbox###1##2{\eqmakebox{$##1##2$}}}
\mathpalette\eqmathbox#{#3}
}
\makeatother
\begin{document}
\[
\renewcommand{\arraystretch}{1.2}
\setlength{\arraycolsep}{0pt}
\begin{array}{ r c r c r c r }
2 x_1 & {}-{} & x_2 & {}+{} & 1.5 x_3 & {}={} & 8 \\
x_1 & & & {}-{} & 4 x_3 & {}={} & -7
\end{array}
\]
\begin{alignat*}{4}
2 x_1 & {}-{} & x_2 & {}+{} & 1.5 x_3 = {} && 8 \\
x_1 & & & {}-{} & 4 x_3 = {} && -7
\end{alignat*}
\begin{align*}
\eqmathbox[x1][r]{2 x_1} - \eqmathbox[x2][r]{x_2} + \eqmathbox[x3][r]{1.5 x_3} &= \eqmathbox[c][r]{8} \\
\eqmathbox[x1][r]{ x_1} \phantom{{}-{}} \eqmathbox[x2][r]{} - \eqmathbox[x3][r]{4 x_3} &= \eqmathbox[c][r]{-7}
\end{align*}
\end{document}
All yield similar output:
Today I see a beautiful equation:
(Sorry for cannot put the pic directly, I'm new here.)
I don't know how to write it in Tex. I try my best to write like following:
\begin{equation}
\begin{aligned}
r_{t}=\left\{
\begin{array}{crl}
1+\dfrac{\bar{R}_{Q}(t+\Delta t)-R_{Q}(t)}{2\Delta t/T_{single}}\; &+0\qquad &if\,\bar{R}_{Q}(t+\Delta t)>0,\\
0 \; &-P\qquad &if\,R_{Q}(t)\neq 0\wedge R_{Q}(t+\Delta t)=0,\\
0\; &+0\qquad &if\,R_{Q}(t)=0
\label{rforProtRwd}
\end{array}
\right.
\\
\underbrace{\hspace{10em}}_{=:r_{t}^{(1)}}\hspace{1em}\underbrace{\hspace{2em}}_{=:r_{t}^{(2)}}\hspace{17em}
\end{aligned}
\end{equation}
It is obviously that the underbrace is a little far from the main part of the equation. And actually both the method I write and the result are ugle.
So I wonder if there are some better ways to write it.
Hoping someone can help.
Here is an accurate \underbrace that matches the content within a cases environment.
\documentclass{article}
\usepackage{mathtools,eqparbox}
\begin{document}
\begin{align}
r_t = \begin{cases}
\eqmakebox[LHS]{$1 + \dfrac{\bar{R}_Q(t + \Delta t) - R_Q(t)}{2 \Delta t / T_{\text{single}}}$}
+ 0 & \text{if $\bar{R}_Q(t + \Delta t) > 0$}, \\
\eqmakebox[LHS]{$0$}
- P & \text{if $R_Q(t) \neq 0 \wedge R_Q(t + \Delta t) = 0$}, \\
\eqmakebox[LHS]{$0$}
+ 0 & \text{if $R_Q(t) = 0$}
\end{cases} \\[-1.2\normalbaselineskip]
\underbrace{\eqmakebox[LHS]{\mathstrut}}_{=:r_t^{(1)}}
\underbrace{\mathstrut\phantom{{} - P}}_{\mathclap{=:r_t^{(2)}}}
\quad\phantom{\text{if $R_Q(t) \neq 0 \wedge R_Q(t + \Delta t) = 0$},} \nonumber
\end{align}
\end{document}
I would like to call a single value from a table inside a textbody.
% latex table generated in R 3.5.1 by xtable 1.8-3 package
% Wed Dec 12 13:56:07 2018
\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
\hline
& Estimate & Std. Error & z value & Pr($>$$|$z$|$) \\
\hline
(Intercept) & -1.819 & 0.926 & -1.964 & 0.050 \\
hiveH2 & 2.418 & 0.951 & 2.542 & 0.011 \\
nectar+ & 0.827 & 0.947 & 0.873 & 0.383 \\
\hline
\end{tabular}
\label{tab:x}
\end{table}
I would like to be able to write something along the line:
The z value of Hive~2 is \call{tab:x{z value}{hiveH2}}.
That should compile as:
The z value of Hive 2 is 2.542.
the LaTeX table was generated with a R script (neither R markdown nor R sweave):
library(lme4)
library(xtable)
data <- matrix(c("H1","H1","H2","H2","H1","H1","H2","H2","H1","H1","H2","H2","H1","H1","H2","H2","H1","H1","H2","H2","H1","H1","H2","H2","H1","H1","H2","H2",
"+","+","-","-","+","+","-","-","+","+","-","-","+","+","-","-","-","-","+","+","-","-","+","+","-","-","+","+",
0.00000000,0.00000000,0.25000000,0.00000000,0.00000000,0.00000000,0.00000000,0.10000000,0.20000000,0.00000000,0.10000000,0.00000000,0.00000000,0.00000000,0.00000000,0.09090909,0.09090909,0.00000000,0.41666667,0.08333333,0.00000000,0.14285714,0.85714286,0.61538462,0.00000000,0.00000000,0.25000000,1.10000000),
nrow=28, ncol=3)
data <- as.data.frame(data)
colnames(data) <- c("hive", "nectar", "severity")
glm <- glm(severity ~ hive + nectar, data = data, family = binomial)
summary.glm <- summary(glm)
summary.glm
print(xtable(summary.glm, type = "latex", caption.placement = getOption("xtable.caption.placement", "bottom"),
digits = 3,
label = "tab:x",
table.placement = getOption("xtable.table.placement", "h")),
file = "test.tex")
I want to left align a block of equations. The equations in the block itself are aligned, but that's not related at all to my question! I want to left align the equations rather than have them centered all the time, because it looks dumb with narrow centered equations.
Example, I want to left align this
\begin{align*}
|\vec a| &= \sqrt{3^{2}+1^{2}} = \sqrt{10} \\
|\vec b| &= \sqrt{1^{2}+23^{2}} = \sqrt{530} \\
\cos v &= \frac{26}{\sqrt{10} \cdot \sqrt{530}} \\
v &= \cos^{-1} \left(\frac{26}{\sqrt{10} \cdot \sqrt{530}}\right) \\
v &= \uuline{69.08...\degree}
\end{align*}
but also this
\begin{align*}
f(x) = -1.25x^{2} + 1.5x
\end{align*}
How is this done? If it's even possible.
Try to use the fleqn document class option.
\documentclass[fleqn]{article}
(See also http://en.wikibooks.org/wiki/LaTeX/Basics for a list of other options.)
You can use \begin{flalign}, like the example bellow:
\begin{flalign}
&f(x) = -1.25x^{2} + 1.5x&
\end{flalign}
Try this:
\begin{flalign*}
&|\vec a| = \sqrt{3^{2}+1^{2}} = \sqrt{10} & \\
&|\vec b| = \sqrt{1^{2}+23^{2}} = \sqrt{530} &\\
&\cos v = \frac{26}{\sqrt{10} \cdot \sqrt{530}} &\\
&v = \cos^{-1} \left(\frac{26}{\sqrt{10} \cdot \sqrt{530}}\right) &\\
\end{flalign*}
The & sign separates two columns, so an & at the beginning of a line means that the line starts with a blank column.
The fleqn option in the document class will apply left aligning setting in all equations of the document. You can instead use \begin{flalign}. This will align only the desired equations.