LaTeX (amsmath): Left aligned equtations in {equation} or {align} container - latex

I have the following problem
\usepackage[fleqn]{amsmath}
\begin{equation}
\begin{split}
\min Y\\
\textrm{s.t.}
\end{split}
\end{equation}
\begin{align}
a+b=145641574\\
c+d<e
\end{align}
creates the following output:
So far so good. The formulas are essentially left-aligned. The numbering is right-aligned. But within the formulas, splits or line breaks result in right alignment. These should also be left-aligned.
Thanks in advance and have a nice weekend!

Related

align enviroment tab and kerning

I have been using common align environment from amsmath and noticed strange behaviour of kerning when placing the & sign from either side of the + sign. Namely assume the following code and the result it produces for me:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a&+b\\
a+&b
\end{align}
\end{document}
Is this a bug? If this is intended behaviour, can you please explain why the kerning is different in those cases?
For all it could matter I am using TexStudio 4.0.1 and MikTex (Console version 4.8, all packages updated on 24th Aug 22) to produce the output from the code.
I think it's working as expected. The ampersand characters defines a boundary between left and right columns, which in turn are right and left aligned, respectively. Everything to the left is pushed leftwards and everything to the right is pushed rightwards.
Consider the code
\documentclass{article}
\usepackage{amsmath}
\setlength\fboxsep{0pt}
\begin{document}
\begin{align}
\boxed{a} \clap{\rule[-3pt]{0.4pt}{12pt}}& + b\\
a + \clap{\rule[-3pt]{0.4pt}{12pt}}& \boxed{b}
\end{align}
\end{document}
IMO there's the perfect split between two columns. The extra spacing comes from + being an operator so LaTeX does add extra spacing around it.
In your code, there is another issue. An ampersand placed at the right of an operator cancels its status of being the operator. The effect is it's losing expected spacing; the same would happen with =. Adding anything between an operator and & restore its status. Therefore, {} placed right before & is he easiest solution
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a & + b \\
a + {}& b
\end{align}
\end{document}

Latex box around set of equation

I would like to display a formula in latex as the following. The space between the left border and the formula should be adjustable to 1cm.
Boxed equation with 1cm space to left border
Thanks in advance!
An easy way to draw frames around aligns is the tcolorbox package:
\documentclass[fleqn]{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcolorbox}[ams align,colback=white]
x &= x\\
&= x
\end{tcolorbox}
\end{document}

How to ensure that the text paragraphs on the right side are consistent in the formula environment in the Latex?

I try to write the following formula in Latex
My question is that how to write the right-hand side formula? How to ensure that the text paragraphs on the right side are consistent in the formula environment?
My code is
$\mathbb{P}[\mbox{there exists a black path from ${0}\times [0,s]$ to $\pho s\mtis [0,s]$ in the rectangle $0,\pho s]\times [0,s]$}]
I suggest:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Text
\[
f_s(\rho)=\mathrm{P}%
\left[
\begin{array}{l}
\text{there exists a black path from }\{0\}\times [0,s]\text{ to}\\
\{\rho s\}\times [0,s]\text{ in the rectangle }[0,\rho s]\times [0,s]
\end{array}
\right].
\]
Text
\end{document}
giving this output:
Comment if this is ok with your code or not! :)

How to have a normal line of text inside a math environment and align it correctly in LaTeX?

I'm a LaTeX beginner and would like to have two equations aligned on the equals symbol which is working fine so far. Now, between these two equations I need a line of text. But LaTeX interprets this as a math formula since it's showing a (2) right next to it.
I would like to have it as normal text without a (2) aligned on the far left.
I have already tried things like
\begin{flushleft} line of text \end{flushleft}
but it's not working, maybe because I'm using it inside an {align} environment.
Not sure if it's important to mention but I'm using Overleaf (online LaTeX editor).
\begin{align}
\tilde{w}_{ij} &=
\begin{cases}
w_{ij} & \text{mit $P(i)$}\\
0 & \text{sonst}
\end{cases}\\
\text{This text be on the far left}\\
\tilde{w}_{ij} &= w_{ij} * P(i)
\end{align}
produces this ->
This sounds like a job for \intertext from amsmath:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
\tilde{w}_{ij} &=
\begin{cases}
w_{ij} & \text{mit $P(i)$}\\
0 & \text{sonst}
\end{cases}\\
\intertext{This text be on the far left}
\tilde{w}_{ij} &= w_{ij} * P(i)
\end{align}
\end{document}

LaTeX math overline/overrightarrow vertical alignment?

When I use the following:
\begin{equation}
\overline{d} \overline{q}
\end{equation}
the overlines are misaligned, with the line on the q being lower than the line on the d. The same thing happens with \overrightarrow. Is there some way to fix this?
\vphantom could fix it:
\begin{equation}
\overline{d} \overline{q\vphantom{d}}
\end{equation}
\vphantom inserts vertical space according to the height of its argument and has zero width.
You can also use
\begin{equation}
\overline{\strut d} \overline{q \strut}
\end{equation}

Resources