New answers tagged

0

\documentclass{article} \usepackage{amsmath} \begin{document} \[ \hat{y}_i= \begin{cases} y_i, & \text{if}\ i\notin I\\ (x\hat{\beta})_i, & \text{if}\ i \in I \end{cases} \] \end{document}


2

From the TeXbook, second doubly dangerous paragraph on page 150: Question: What happens if a subscript or superscript follows a large delimiter? Answer: That's a good question. After a \left delimiter, it is the first subscript or superscript of the enclosed subformula, so it is effectively preceded by {}. After a \right delimiter, it is a subscript or ...


1

not finding an earlier question addressing this situation, here is my suggestion: add a \vphantom to the numerator of the fraction on the left to make it appear to be the same size as the fraction on the right: N = \left( \frac{s\vphantom{d}}{2} \right)^2 - \left( \frac{d}{2} \right)^2


5

Here's a solution that uses side-by-side minipage environments but no multicols environment. Since the minipages are quite narrow, I suggest you use raggedright rather than full justification; this may be achieved by loading the ragged2e package with the option document. To align the variables within an equation, use \phantom statements along the lines used ...


3

This may not be ideal visually, but addresses your concern: \documentclass{article} \usepackage{amsmath,eqparbox} \usepackage{xcolor,booktabs,tabularx} \usepackage[makeroom]{cancel} \usepackage[margin=1cm]{geometry} \begin{document} \begin{enumerate} \item[34.] Solve the system using elimination by addition. \begin{alignat*}{3} x + y + z &...


3

Same idea, only for displayed math. The environments eqnsize and eqnsize* are similar to equation and equation*. Note that \tag and \notag were implemented. I originally tried to incorporate as much of amsmath as possible, but eventually got hopelessly lost. Comparing eqnsize and eqnsize* one finds a lot of common code that could be moved to a separate ...


4

How about this: two aligned environments and an \eqparbox in between, nested in flalign. Eqparbox allows to have a \parbox of width the longest line width of the paragraph: \documentclass[10pt]{article} \usepackage{amsmath, amsthm, amssymb} \usepackage{array, eqparbox} \usepackage{booktabs} \usepackage[makeroom]{cancel} \begin{document} Solve the system. \...


8

Something like this? \documentclass[10pt]{article} \usepackage{amsmath, amsthm, amssymb} \usepackage{array} \usepackage{booktabs} \usepackage[makeroom]{cancel} \begin{document} \noindent \begin{minipage}{0.45\textwidth} Solve the following system: \begin{align*} 6x-5y &= 11 \\ 7x+5y &= 2 \end{align*} \end{minipage} \bigskip\...


5

You can define a simple macro, in which you can make a comparison of lengths, here is an attempt using the calc package and \resizebox command from the graphicx package. \documentclass{article} \usepackage{graphicx} \usepackage{calc} \newlength{\eqhsize} \newcommand{\myinlineeq}[1]{% \setlength{\eqhsize}{\minof{\widthof{\mbox{\ensuremath{#1}}}}{\...


3

here's one possibility: \documentclass{article} \usepackage{mathtools} \begin{document} \begin{gather} 8 \pi G a \bar{\rho}+\bar{p} \partial \delta u = - \dot{a} \partial E + a \partial\dot{A} \\[\jot] \begin{multlined} 4 \pi K ( \delta\rho + 3 \delta p + \nabla \phi^S )\\ = -\frac{1}{2 a^2} \nabla T - \frac{3 \dot{a}}{2 a} \dot{E} - \frac{1}{a} \nabla \...


4

one possibilities is use multlined environment from package mathtools: \documentclass[10pt]{amsart} \usepackage{mathtools} \begin{document} \begin{gather} 8 \pi G a \bar{\rho}+\bar{p} \partial \delta u = - \dot{a} \partial E + a \partial\dot{A} \\ 4 \pi K ( \delta\rho + 3 \delta p + \nabla \phi^S ) = \begin{multlined}[t][.5\...


0

You can use \centerline in combination with the minipage environment for this purpose: \centerline{ \begin{minipage}{\linewidth} \begin{align*} \text{I am very looooooooooooooooooooooooooooooong} & \text{Me toooooooooooooooooooooooooooooooooooooooo!} \end{align*} \end{minipage} } The minipage environment embeds a virtual page, ...


0

\documentclass{article} \usepackage[active,tightpage]{preview} \usepackage{amsmath} \pagestyle{empty} \begin{document} \begin{equation} 1-\strut\displaystyle\frac{2\,M}{r}, \quad \text{for}\, r>R, \end{equation} foo $ xy=f(x) $ bar foo \[ dy=g(x) \] bar \end{document} Latex to SVG cmd $latex test.tex $dvisvgm.exe ...


0

LaTeX to SVG latex test.tex dvisvgm.exe -n -p 1-5 -c 1.2,1.2 test.dvi


0

Or even shorter: \documentclass{article} \newcommand{\eq}[2]{\begin{equation} \label{eq:#1} #2 \end{equation}} \begin{document} \eq{1}{x + y = z} \eq{2}{a + b = c} \end{document} After you type in your doc, you can "translate" back your source tex file to regular environments with sed or alike. I do this very often despite what others have ...


2

Use the below: \documentclass{article} \makeatletter \newcommand{\beq}[1]{\begin{equation}\label{eq:#1}} \newcommand{\eeq}{\end{equation}} \makeatother \begin{document} \beq{1} x + y = z \eeq \beq{2} x + y = z \eeq \end{document} Output:


2

Set the items as inline math prepended with \qquad (a 2em space). You can switch to \displaystyle if needed: \documentclass{article} \begin{document} \begin{itemize} \item {\itshape Partition of unity.} \qquad $\displaystyle \sum_{i=1}^{p+1} B^p_i (\xi) \quad \forall \xi \in [-1,1]$ \item {\itshape Pointwise nonnegativity.} \qquad $B_i^p(\xi) ...


1

Here is another way to do it, which is probably better than my other answer. You get the correct spacing, and you can align the equations better to each other, if desir​eble, as the equations are kept in just one environment. Also, less code. Output Code \documentclass[11pt]{article} \usepackage{mathtools} \makeatletter \newcommand{\alignleft}{% \@...


2

There are many ways to do this, including the enum-package, which could be great for consistency, or a simple newcommand. Output Code \documentclass[11pt]{article} \usepackage{mathtools} \makeatletter \newcommand{\alignleft}{% \@fleqntrue\@mathmargin3em% \setlength{\abovedisplayskip}{4pt} % \setlength{\belowdisplayskip}{4pt} % } \...


3

This is simply to show how to reformat the equation with as little effort as possible. Copy the line to be broken. Use \right. or \left. to balance an otherwise unmatched \left or \right. Use \hphantom to preserve spacing, and \vphantom to preserve the \left ... \right size. Note, the additional \qquad is to compensate for the missing = and \{. \...


1

You can do it (but only for equations in any of the amsmath environments). But it is wrong, very wrong: you should think ahead before tweaking this way the cross reference mechanism. When you search for labels, you'll have no clue what each one refers to without first knowing what section the reference/label appears in. \documentclass{article} \usepackage{...


5

You check for math mode and then use \mathpalette: \documentclass{article} \usepackage{amsmath} \makeatletter \newlength{\negph@wd} \DeclareRobustCommand{\negphantom}[1]{% \ifmmode \mathpalette\negph@math{#1}% \else \negph@do{#1}% \fi } \newcommand{\negph@math}[2]{\negph@do{$\m@th#1#2$}} \newcommand{\negph@do}[1]{% \settowidth{\negph@wd}{#1}...


4

You can use breqn package for this: \documentclass{article} \usepackage{amsthm,amsmath,breqn,lipsum} \usepackage[showframe,margin=5cm]{geometry} \begin{document} \lipsum[1-2] \begin{frame}[shrink=0, t]{The \textbf{\textit{DP}} Algorithm} \begin{center} \begin{minipage}{.9\textwidth} \begin{proof} \begin{enumerate} ...


3

Is this what you are after? Your problem was in the dollar signs around 3.3. You don't need to do add dollar signs when already inside a math-environment. Besides, 3.3 can be written both in normal text mode and in math. Output Code \documentclass[11pt]{article} \usepackage{fontspec} \usepackage{siunitx} \usepackage{mathtools} \begin{document} \begin{...


1

The idea is the same as Mico's, but the realization is perhaps simpler, with eqparbox: \documentclass{article} \usepackage{amsmath} \usepackage{eqparbox} \begin{document} \begin{align*} \mathcal{L} &= {\underbrace{\eqmakebox[g]{$g\langle\bar{\nu}\nu\rangle$}}}\bar{\nu}\nu \\ &= \eqmakebox[g][c]{$m_{\nu}^2$} \bar{\nu}\nu \end{align*} \...


3

I would suggest using the array environment for simplicity of syntax and decent spacing with easy access to change the vertical spacing if necessary. Further the default vertical space under underbrace isn't too excessive. If $b+c = d$, then \[ \begin{array}{r @{{}={}} c @{{}+{}} l} a & \underbrace{b + c} & e + f\\ & d ...


1

Maybe my code looks simpler and more elegant, but I did copy Mico code for the \nu and so on (hehe). And Most part I adapted from David answer. \documentclass{article} \usepackage{mathtools}% http://ctan.org/pkg/mathtools \begin{document} \begin{align*} \begin{array}{r@{}l@{\,}l} \mathcal{L}=& \enskip g\langle\bar{\nu}\nu\rangle& \bar{\nu}\nu\\ ...


3

A combination of an align* environment, an \underbrace instruction, and a fixed-width (centered) parbox get the job done: \documentclass{article} \usepackage{amsmath} % for '\underbrace' macro and 'align*' env. \newlength\mylen \newcommand\gterm{{\underbrace{g\langle\bar{\nu}\nu\rangle}}} \settowidth\mylen{$\gterm$} \begin{document} \begin{align*} \...


6

This is the aligned environment: \begin{equation} \begin{aligned} a&=1+2+3 & b&=4+5+6\\ c&=2+4+6 & d&=3+5+7 \end{aligned} \end{equation} If you want to have control on the gap between groups of alignments, you can use the alignedat{n} environment, where n is the number of groups, requiring 2n-1 ampersands. \begin{equation} \...


7

The basic building block you can use is \left\{ \begin{aligned} .... \end{\aligned} \right. If you want the q+1 in front then just write it before the \left\{. You want three such groups on separate lines apparently with one single equation number, so you can place these groups in to \begin{equation} \begin{gathered} ...\\ ---\\ ...


0

I've manage to do what you need with nested tcolorbox. I've painted in red just to demonstrate a very long equation, the white background area inside is the description box. \documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{breakable} \usepackage{amssymb} \usepackage{amsmath} \usepackage{lipsum} \begin{document} \begin{tcolorbox}[...


3

Like this? Considering comments to question, the code employ empheq package and also environment multlined from package mathtools, which is called by empheq: \documentclass{article} \usepackage[a4paper,margin=1in]{geometry} \usepackage{empheq} \begin{document} \begin{empheq}[left={f(x)=}\empheqlbrace]{align} x_1, & \text{ if } x\in \...


2

The following sets up a specific numcases environment to have the sequential numbering C1, C2, Ck, Cn using \setupnumcases. The setup is restored using \restorenumcases. The idea is to update \theequation - the macro responsible for setting the equation counter or representation - to set a specific list of possibilities in sequence. This sequence is ...


1

Set \postdisplaypenalty to 10000 for the special case: \documentclass[11pt]{article} \usepackage{amsmath} \usepackage{lipsum} % just for the example \newcommand{\commentedequationtext}{} % initialize \newenvironment{commentedequation}[1] {\renewcommand\commentedequationtext{#1}% \postdisplaypenalty=10000 \equation} {\endequation\...


2

You could put it into a minipage, or use the samepage-package. I've added here the mathtools-package, which I would advice you to use. As commented by David Carlisle, you shouldn't spell out complete words in math-environments, as each individual letter will be typeset as a variable. You could put them in \text{Word}. Code \documentclass[11pt]{article} \...


2

If you want to increase spacing for all dcases environments, you can use the \renewcases command from mathtools. Here is an extremist example: \documentclass{article} \usepackage{mathtools} \makeatletter \renewcases{dcases}{\,}{% $\m@th\displaystyle{##}$\hfil}{$\m@th\displaystyle{##}$\hfil}{\lbrace\qquad}{.} \makeatother \begin{document} \[ \frac{\...


0

I realised while writing the question that these could be two options: \[ \begin{dcases*} \quad l_{\epsilon} = (l_ul_d)^{1/2}\\ ~ l_k = min(l_u,l_k) \end{dcases*} \]


0

The problem arsises with the use of the clevref package. Eliminating it solves the problem.


0

You can do that with alignedat: \documentclass{article} \usepackage{mathtools} \begin{document} \begin{equation} \begin{alignedat}{2} ∑ F_x: & \qquad & & \mathllap{ -}Q · \cos γ- L · \sin β+ R_{B_x} = 0 \\ ∑ F_y: & & & Q · \sin γ+ L · \cos β+ R_{B_y} - mg = 0 \\ ∑ (M_z)_B: & & & mgh · \cos β- ...


0

OK, I came up with following solution: \begin{subequations} \label{eq:equilibrium} \begin{align} &\sum F_x: && -Q \cdot \cos \gamma - L \cdot \sin \beta + R_{B_x} = 0\\ &\sum F_y: && Q \sin \gamma + L \cos \beta + R_{B_y} - mg = 0 \\ &\sum (M_z)_B: && mgh \cdot \cos \beta - Lh - Qa \cdot \cos(90 - \beta - \gamma) = ...


0

To typeset a multi-line system of equations with a single, vertically centered equation number, you might use a split environment inside an equation environment: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \begin{split} \sum F_x &\colon {-}Q \cos \gamma - L \sin \beta + R_{B_x} = 0\\ \sum F_y &\colon Q \sin \...


3

The undefined control sequence is \text, which is defined by package amstext, which is automatically loaded by amsmath. Thus, the minimal \usepackage{amstext} or the more powerful \usepackage{amsmath} fixes the issue.


4

Here is a simple solution with blkarray: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[showframe]{geometry} \usepackage{amsmath} \usepackage{array, blkarray} \newcommand\eqcomment[1]{\fbox{\makebox[4cm]{#1}}} \begin{document} \[ \setlength\BAextrarowheight{3pt} \hspace*{-5cm} \begin{...


4

(too long for a comment, hence posted as an answer) Make sure you don't use both \[...\] and \begin{equation} ... \end{equation} simultaneously to encase your displayed equation. Use one or the other method, but not both at the same time. \documentclass{article} \begin{document} \begin{equation} \label{eq:tau} -1 \leq \tau \leq 1 \end{equation} A cross-...


5

An excerpt from page 135 of the TeXbook: ... [A] blank line or \par is not permitted in math mode. This gives TeX another way to recover from a missing $; such errors will be confined to the paragraph in which they occur. Knuth provides the following example to motivate this syntax rule: For example, suppose you were to write The smallest $n ...


4

This is a standard application of an equation with a \text addition (you could also use \mbox): \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} T_n = \frac{4L}{(2n+1)\sqrt{gH}}, \quad \text{for mode $n = 0,1,2,3,\dots$} \end{equation} \end{document}


2

You can use the multlined environment from mathtools. I took the liberty to replace the pairs of \big( … \big) and the like with \bigl( … \bigr). \documentclass{beamer} \usepackage{mathtools} \begin{document} \begin{frame} \frametitle{MWE:Split one equation in align environment} \begin{align} L_e(c_k^{(i)}) &=\log\frac{f_n(\tilde{c}_k|c_k^{(i)}=p)}{...


1

Here is one of the typical ways to achieve this alignment with respect to the = sign: \documentclass{beamer} \begin{document} \begin{frame} \frametitle{MWE:Split one equation in align environment} \begin{align} L_e(c_k^{(i)}) ={}& \log\frac{f_n(\tilde{c}_k|c_k^{(i)}=p)}{f_n(\tilde{c}_k|c_k^{(m)}=q)} \\ ={}& \log\frac{...


3

You can used the \Aboxed command, from empheq, which can bow a single equation. I adapted the code to define a \Ashaded and a Acolorboxed command, which use shadecolour, bgcolour and rulecolour parameters, to be defined with \colorlet. \documentclass[x11names]{beamer} \usepackage{empheq} \makeatletter \colorlet{shadecolour}{Thistle3!50} \newcommand\...


1

While \midrule works in aligned, you get much finer control with array. \documentclass{article} \usepackage{amsmath,booktabs,cancel,array,xcolor} \newcommand{\rs}[1]{\textcolor{red}{#1}} \begin{document} \begin{equation} \renewcommand{\arraystretch}{1.2} \begin{array}{@{}r@{}>{{}}l@{}} 6x\; {\cancel{-\;5y}} &= 11 \\ 7x\; {\cancel{+\;5y}} &= 2 ...



Top 50 recent answers are included