New answers tagged

6

\documentclass{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} %\DeclareUnicodeCharacter{2026}{\dots}% … % \u8:… ->\IeC {\dots } \expandafter\def\csname u8:\detokenize{…}\endcsname#1{\dots#1} \begin{document} $\left\{a \dots \right\}$\vline $\left\{a … \right\}$\vline \end{document} \dots looks ahead at the next token to see whether ...


5

You have a spurious extra \\ after the first equation. Remove it, and the extra line will disappear. For the second equation, do consider using a cases environment; for one, the left-hand curly brace will be a bit larger. \documentclass{article} \usepackage{amsmath} % for 'cases' env. and `\text` macro \numberwithin{equation}{section} % just for this ...


0

Load amsmath. \begin{document} \begin{equation} u(x,t) = 0 \text{ si } x = 0, x = 1\label{ex1bc} \end{equation} \begin{equation} u(x,0)=\begin{cases} x, & \text{si $0 \le x \le 1/2$}, \\ 2(1-x), & \text{si $1/2 \le x \le 1$.} \\ \end{cases} \end{equation} \end{document}


3

\usepackage{tikz} \usetikzlibrary{arrows.meta} \newlength\tmplength \newcommand*\textarrow[2][3em] {\mathrel{\vcenter{\hbox{\settowidth\tmplength{\scriptsize#2}% \tikz[font=\scriptsize] \draw[->](0,0)--node[fill=white,midway]{#2} ++({#1+\the\tmplength},0);}}}} and ...


4

I'd use smaller type vertically centered with respect to the math axis: \documentclass{article} \usepackage{amsmath} \newcommand{\crightarrow}[1]{% \relbar\joinrel\joinrel\relbar\mathrel{\vcentertext{#1}}\rightarrow } \newcommand{\vcentertext}[1]{% \vcenter{\hbox{\scriptsize\smallstrut#1}}% } \newcommand{\smallstrut}{\vrule height 1.5ex depth 0.5ex ...


6

I propose this: \documentclass{article} \usepackage{amsmath} \newcommand{\mytextarrow}[1]{\mathrel{\relbar\mkern-10mu\relbar\mkern-3.5mu\raisebox{0.25ex}{\scriptsize#1}\!\rightarrow}} \begin{document} \begin{equation*} 2 + 2 \mytextarrow{goes to} 4 \end{equation*} \end{document}


2

\documentclass{article} \usepackage{amsmath} \newcommand{\textarrow}[1]{-\text{#1}\to} \begin{document} \begin{equation*} 2 + 2 \textarrow{goes to} 4 \end{equation*} \end{document}


3

In LaTeX, \begin{foo} and \end{foo} actually call the commands \foo and \endfoo, so you can try modify them directly if the \newenviornment method doesn't work. With the particular case of the gather environment, I believe it changes the way certain characters are handled which I think is the cause of the issue. This can be solved by preventing \gather ...


3

The simplest way to do this is to use an array inside your math environment with centered columns. \documentclass{article} \begin{document} \[ \setlength{\arraycolsep}{3em} \begin{array}{c c} 1 & 1 \\ 1\quad1 & 1\quad1 \\ 1\quad2\quad1 & 1\quad2\quad1 \\ 1\quad3\quad3\quad1 ...


2

The systeme package does this in a very pretty way: \documentclass{article} \usepackage{amsmath} \usepackage{systeme} \begin{document} \[ \systeme{ x_{1} - 3x_{2} + 4x_{3} = -4, 3x_{1} - 7x_{2} + 7x_{3} = -8, -4x_{1} + 6x_{2} - x_{3} = 7 } \] \end{document} If you search on the site for systeme, you'll find several other examples. For ...


0

I would use: \documentclass{amsart} \begin{document} \[ \max\{\, x e^{-x^2}\mid 0\le x\le 1\, \} \] \end{document} giving


2

Here's a possibility: \documentclass{article} \usepackage{amsmath} \makeatletter \everymath{\if@display\else\thickmuskip=2mu plus 2mu\fi} \makeatother \begin{document} \begin{center}% just to show the effect $a=b$ \end{center} \[ a=b \] \end{document} Alternatively (and preferably), but this requires using \(...\) for inline math: ...


1

To answer your question 4 about fonts, you can get a good list of Type 1 math fonts usable by PDFLaTeX, with samples, at the LaTeX Font Catalogue. I personally like \usepackage[osf,slantedGreek]{mathpazo} This gives you an attractive Palatino clone with excellent coverage. You can combine it with other math symbol packages, such as amssymb, boondox and ...


9

multi-question questions don't really fit the site format but.. Do you think that it is Ok to recommend the mathtools package instead of amsmath package. The mathtools package calls the amsmath package and improves it as far as I understand. Yes What about the empheq package It's OK but more of a "contrib" package than mathtools which aims to ...


1

Here's a version with tcolorbox and its \tcbhighmath command, wrapped in `\highlightnew: \documentclass{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{color} \usepackage[most]{tcolorbox} \setlength{\fboxsep}{0pt} \newcommand{\highlight}[1]{\text{\colorbox{yellow}{$#1$}}} ...


2

Once you're in the \colorbox, LaTeX forgets that you were in math mode and it forgets the type of font you were using. In math mode there are four different sizes: \displaystyle \textstyle \scriptstyle \scriptscriptstyle If you rewrite you third equation as \(\frac{-b\pm \sqrt{\colorbox{yellow}{\(\scriptstyle b2- 4ac\)}}}{2a}\) then you'll get the ...


3

The amsmath package sets \if@display to true in displays; the primitive \textstyle has no influence over it. Since the standard definition of \pmod checks \if@display, you get the additional space nonetheless. You have two strategies available. First strategy: redefine \pod (which \pmod depends on) so it doesn't add the space. This can be done with ...


1

Something like that? \documentclass{article} \usepackage{amsmath} \usepackage{fourier} \usepackage{mathtools} \begin{document} \begin{alignat*}{2} x &= a + b &\\[-1ex] & & {} + c + d & \\ % this line should be aligned to the right y &= a + b \\[-1ex] & & \mathllap{{}+ c + d + e} & % this should be aligned ...


0

I recommend the usage of the simple command \hspace{xcm}. The \hspacecommand when put infront of an equation, pushes it farther towards the right and the shift is basically defined by the user in cm. I haven't tried left shifts but I guess negative values within the braces can get the job done. Additionally, to align the equations, one can use an ampersand ...


4

The Computer Modern fonts lack sans serif boldface slanted, but the Latin Modern fonts have it. \documentclass{article} \usepackage{amsmath} \DeclareMathAlphabet{\mathsfit}{OT1}{lmss}{m}{sl} \DeclareMathAlphabet{\mathsfbfit}{OT1}{lmss}{bx}{sl} \begin{document} $\mathsfit{z}\ne\mathsfbfit{z}$ \end{document} A slightly different solution that avoids ...


3

For making Math appear Sans Serif, you can load cmbright, but this will make all math like that. You can see this question for switching between it and none: Make mathfont respect the surrounding family You can then use \boldsymbol{} for making it bold. \documentclass{article} \usepackage{amsmath} \usepackage{cmbright} \begin{document} $\boldsymbol{z}$ ...


3

You can specify the distance between the rows by adding the optional argument to the newline command as in: \\[2.5ex] \documentclass{article} \usepackage{amsmath,amssymb} \usepackage{array} \pagestyle{empty} \begin{document} \begin{equation}\label{test} \newcolumntype{Y}{>\displaystyle c} \left|\frac{D(u,v)}{D(x,y)}\right|= \left| ...


0

There is in fact a package option for this: if you pass noBBpl to mathpazo, then its blackboard bold fonts are not loaded. That also means you have to load the AMS ones separately, but that just means using amssymb, which is simpler than defining another symbol font alphabet: \documentclass{article} % these two \usepackage commands make it work ...


3

I don't see why you'd like to go via new theorem definitions. You can just define a new counter and alias LaTeX's equation counter to it. Here's my version of a macro \makeeqcontext (adapted from some earlier code I had written for myself at some point): \makeatletter \def\makeeqcontext#1#2{% \edef\tmp@eqcontextcountername{eqcounter#1}% ...


4

Define new environments: \documentclass{article} \usepackage{amsmath} \newtheorem{typea*}{Type A} \newtheorem{typeb*}{Type B} \newenvironment{typea} {\setcounter{equation}{\value{typea*}}\begin{subequations}\begin{typea*}} {\end{typea*}\end{subequations}} \newenvironment{typeb} {\setcounter{equation}{\value{typeb*}}\begin{subequations}\begin{typeb*}} ...


5

Just use an array here. You may want to add one more @{} or some other spacer onto the left of the first column. % arara: pdflatex \documentclass[12pt]{article} \usepackage[version=4]{mhchem} \usepackage{siunitx} \begin{document} \setcounter{equation}{4} \begin{equation} \ce{^235_92U + ^1_0n -> ^236_92U^* ->[{\SI{85}{\percent} nuclear ...


1

As far as I can make out the intended result is \documentclass{article} \usepackage[T1]{fontenc} \usepackage{amsmath} \begin{document} \begin{equation} \begin{pmatrix} \mathrm{d}'\\ \mathrm{s}'\\ \mathrm{b}' \end{pmatrix} \end{equation} \end{document}


3

Disclaimer: Because a minimal example is missing, I do not know, where your large vertical space comes from. I had to increase the spacing to get it square with a plain document class. Usually the vertical spacing inside a tabular or array can be influenced by setting \arraystretch: \documentclass{article} \usepackage{arydshln}% \hdashline ...


2

(The following code uses math examples you posted initially.) Depending on the type of alignment you want, one of the following two solutions may work for you. \documentclass{article} \usepackage{array} \begin{document} If you want flush-left alignment: \[ f\colon \begin{array}{>{\displaystyle}l} X \rightarrow Y \\ x\mapsto ...


2

yet another possibility -- use aligned within multline: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{multline*} [((a_0, a_1, a_2)+(b_0, b_1, b_2)) + (c_0, c_1, c_2)] \\ \begin{aligned} &= [((a_0 + b_0, a_1 + b_1, a_2 + b_2)) + (c_0, c_1, c_2)] \\ &= (a_0 + b_0 + c_0, a_1 + b_1 + c_1, a_2 + b_2 + c_2) \end{aligned} \\ ...


1

Here is a simple solution by manually inserting white space: \begin{align*} [((a_0, a_1, a_2)+(b_0, b_1, b_2)) + (c_0, c_1, c_2)] &= [((a_0 + b_0, a_1 + b_1, a_2 + b_2)) \\ &~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + (c_0, c_1, c_2)] \\ &= (a_0 + b_0 + c_0, a_1 + b_1 + c_1,\\ ...


0

Here's a hack: introduce a new variable, like so: We now compute the sum $S$ of our three vectors: \begin{align*} S&=[((a_0, a_1, a_2)+(b_0, b_1, b_2)) + (c_0, c_1, c_2)]\\ &=[((a_0 + b_0, a_1 + b_1, a_2 + b_2)) + (c_0, c_1, c_2)]\\ &=(a_0 + b_0 + c_0, a_1 + b_1 + c_1, a_2 + b_2 + c_2) \end{align*} This costs an extra line, but is well ...


1

I would suggest putting the = on its own line along with a \quad spacing before the =. To ensure that the first line does not effect the alignment use mathrlap. Also, if you are using this within an enumerate list, then you can use aligned. This is assuming that there is not additional text before the math environment. Otherwise, use align*. Notes: ...


4

Two more alternatives: \documentclass[border=3mm,preview]{standalone} \usepackage{mathtools} \begin{document} The first option: \begin{align*} [((a_0, a_1, a_2) + & (b_0, b_1, b_2)) + (c_0, c_1, c_2)] \\ & = [((a_0 + b_0, a_1 + b_1, a_2 + b_2)) + (c_0, c_1, c_2)] \\ & = ( a_0 + b_0 + c_0, a_1 + b_1 + c_1, a_2 + b_2 + ...


1

Try using eqnarray like this: \begin{eqnarray} [((a_0, a_1, a_2)+(b_0, b_1, b_2)) + (c_0, c_1, c_2)] & = & [((a_0 + b_0, a_1 + b_1, a_2 + b_2)) \\ & & + (c_0, c_1, c_2)] \\ & = & (a_0 + b_0 + c_0, a_1 + b_1 + c_1, \\ & & a_2 + b_2 + c_2) \\ ...


2

You can do a case branching with expl3 and xparse: \documentclass{article} \usepackage{amsmath,amssymb,xparse} \ExplSyntaxOn \NewDocumentCommand{\zenbu}{m} { \pteromys_zenbu:n { #1 } } \cs_new_protected:Nn \pteromys_zenbu_in:n { (\,\forall #1) } \cs_new_protected:Nn \pteromys_zenbu_sqsubseteq:n { [\,\forall #1] } \cs_new_protected:Nn ...


0

it's possible to use aligned within align, as follows: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} \theta & = \begin{aligned}[t] & \! \theta(t-1) -p \theta(t-1) +p \frac{\hat{\psi}'(\theta(t-1))}{K} +p \phi_R(0)\\ &\qquad + (1-p)(1-\theta(t-1))\\ \end{aligned}\\ R &= ...


3

You write your equation an quite complicated way. Tray: \documentclass{article} \usepackage{mathtools} \usepackage[active,displaymath,tightpage]{preview}% for show only tcolorbox \setlength\PreviewBorder{1em} \begin{document} \begin{align*} E(X) & = \sum_{x=0}^{\infty}x\frac{e^{ - \lambda }\lambda ^x}{x!} \\ & = ...


14

The amsmath package provides a number of options. The leading letter before matrix indicates the delimiter that is used: p for parens, b for brackets, v for verts, B for braces, V for double verts. \documentclass{article} \usepackage{amsmath,tabstackengine} \begin{document} \[ \begin{matrix} 1&2&3\\ 4&5&6\\ 7&8&9 \end{matrix} \quad ...


2

split ought to work inside align, but it has some problems; a trick solves the issue: \documentclass{article} \usepackage{amsmath,mathtools} \newcommand{\ave}[1]{\langle #1\rangle}% <--- guess \begin{document} \begin{align} \begin{split} \mathllap{\theta} &= \theta(t-1) -p \theta(t-1) +p \frac{\hat{\psi}'(\theta(t-1))}{\ave{K}} +p ...


1

The trick is to use the aligned environment, which acts as a single line for the purposes of equation numbering, alignment inside other environments, etc. You'll also want to remove the \nonumber: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \begin{aligned} \theta &= \theta(t-1) -p \theta(t-1) +p ...


5

One option is to update \chapter and insert a regular \label. The structure should be something that you're not going to use elsewhere in the document, of course, since \labels have to be unique. I've chosen to insert \label{chapter-\thechapter}, which is similar to \label{chapter-2} in Chapter 2 if \thechapter is \arabic{chapter} (the defaut). To ...


2

If I complete your fragment to make a document \documentclass{article} \usepackage{amsmath} \begin{document} Blah blah blah, then \[\begin{align*} \label{eq1} \text{something text} &= \frac{a}{b} \\ &= \frac{a}{c+d} \\ & \intertext{some other text, gives} \\ \label{eq2} a &= b+c \end{align*}\] \end{document} then TeX produces ! ...


4

Simple, just use the [t] option for the aligned construct. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation*} \begin{aligned}[t] \frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial \mu} & = -\frac{1} {2\sigma^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)=0 \\ & = ...


0

You could do something like this to avoid having to enter the steps "in parallel" however it was too wide to fit in two columns so I split some lines up, perhaps your linewidth so now it looks a bit spaced out. But the basic idea is to use \allowdisplaybreaks and multicols \documentclass{article} \usepackage{amsmath,multicol} \allowdisplaybreaks ...


3

What you want, as I understand it, is best obtained with alignat environment, from amsmath: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{alignat*}{2} \frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial \mu} & = -\frac{1} {2\sigma^{2}} \sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)=0 & \qquad\qquad \frac{\partial l(\mu, ...


1

eqnarray is already math so you should not have $ but (a) eqnarray should not be used, amsmath provides align and (b) there is no alignment here at all so you just want \[ \[ \underset{\mathbf{S}}{\operatorname{arg\,min}} \sum_{i=1}^{k} \sum_{\mathbf{x} \in S_i} \| \mathbf{x} - \boldsymbol{\mu}_i \|^2 \] Note _ for subscripts not \_


3

It would be better to use an environment designed for aligning displayed equations such as align from amsmath (which would set the display in display math mode and put the right space around the =. array is designed for matrices and sets its content in inline math mode and is not optimised for aligning a single equation. \begin{array}{rcl} means a three ...


3

It doesn't need to have such spacing. \newcommand*\grad[1]{\nabla\mathord{#1}} % and use like \grad{f} If you want to ensure a small space (like before differentials, for instance) you could add \mathop{}\! \newcommand*\grad[1]{\mathop{}\!\nabla\mathord{#1}} Of course you can drop the argument and the \mathord{#1} part, but I think it does no harm ...


3

Another solution is to use \parbox, as suggested here. Code with \parbox, centered as suggested here: \documentclass[a4paper]{report} \usepackage[utf8]{inputenc} \usepackage{amsmath,amssymb,amsfonts,mathtools,newtxtext,newtxmath} \begin{document} \[\left\|\int\limits_0^Re^{-\lambda ...



Top 50 recent answers are included