Remove indent in equation LaTex - latex

I have a rather simple problem. I have an unwanted indent in my equation.
\documentclass[11 pt, a4paper, fleqn]{article}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amsmath}
\setlength{\mathindent}{0cm}
\begin{document}
\noindent Through rigorous analytical calculations found in \textbf{Appendix A} a state space representation was found:
\begin{multline}
X= \begin{pmatrix}\dot{x_1} \\ \dot{x_2} \\ \dot{x_3} \end{pmatrix} =
\begin{pmatrix}0 & 1 & 0\\ 0 & 0 & 1 \\ -1000 & -300 & -30\end{pmatrix}
\begin{pmatrix}x_1 \\ x_2 \\ x_3 \end{pmatrix}+\begin{pmatrix} 0 \\ 0 \\ 160 \end{pmatrix}u \\
\noindent Y=\begin{pmatrix}1 & 0 & 0 \end{pmatrix} \begin{pmatrix}
x_1 \\ x_2 \\ x_3 \end{pmatrix}
\end{multline}
\end{document}
Which give me this result:
enter image description here
I would like to have the second line at the left margin.
I have tried using \[ \begin{aligned} \end{aligned} \] and at the before I begin my document I have the command \setlength{\mathindent}{0cm} but still the indent persists. It's driving me quite mad.
Please and thank you!
edit: made compileable

You can use:
\begin{align}
X &= \begin{pmatrix}\dot{x_1} \\ \dot{x_2} \\ \dot{x_3} \end{pmatrix} =
\begin{pmatrix}0 & 1 & 0\\ 0 & 0 & 1 \\ -1000 & -300 & -30\end{pmatrix}
\begin{pmatrix}x_1 \\ x_2 \\ x_3 \end{pmatrix}+\begin{pmatrix} 0 \\ 0 \\ 160 \end{pmatrix}u \\
Y &=\begin{pmatrix}1 & 0 & 0 \end{pmatrix} \begin{pmatrix}
x_1 \\ x_2 \\ x_3 \end{pmatrix}
\end{align}
Use align* if you don't want line numbers.
I hope that works!

The multiline environment is specifically meant for a single equation which is too long for one line. The first line will align to the left, the second to the right.
If you want to align multiple different equations, I would use something like the align environment as #HelloWorld shows in their answer.
However just for completeness, you can also do this with multiline:
\documentclass[11 pt, a4paper, fleqn]{article}
\usepackage{float}
\usepackage{amssymb}
\usepackage{amsmath}
\setlength{\mathindent}{0cm}
\begin{document}
\noindent Through rigorous analytical calculations found in \textbf{Appendix A} a state space representation was found:
\begin{multline}
X= \begin{pmatrix}\dot{x_1} \\ \dot{x_2} \\ \dot{x_3} \end{pmatrix} =
\begin{pmatrix}0 & 1 & 0\\ 0 & 0 & 1 \\ -1000 & -300 & -30\end{pmatrix}
\begin{pmatrix}x_1 \\ x_2 \\ x_3 \end{pmatrix}+\begin{pmatrix} 0 \\ 0 \\ 160 \end{pmatrix}u \\
Y=\begin{pmatrix}1 & 0 & 0 \end{pmatrix} \begin{pmatrix}
x_1 \\ x_2 \\ x_3 \end{pmatrix}\hfill
\end{multline}
\end{document}

Related

How to top align a table in a table LaTeX

so i started working with latex and i'm trying to fit a table with statistical content into another table for better alignment.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx,dashrule}
\usepackage{tabularx}
\usepackage{xcolor}
\usepackage[a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm]{geometry}
% Document metadata
\title{Statistische Auswertung}
\author{Automatisch Generiert}
\date{2023-02-09 16:24:04}
\begin{document}
% Dokumententitel und Datum generieren
\maketitle
\begin{tabularx}{\textwidth}{|X|X|}
{\begin{tabularx}{\linewidth}{|X|X|}
\hline
age & --- \\
count & 343.0 \\
mean & 60.8 \\
std & 12.1 \\
min & 28.0 \\
25\% & 53.0 \\
50\% & 60.0 \\
75\% & 70.0 \\
max & 89.0 \\
\hline
\end{tabularx}} & \frame{\includegraphics[width=\linewidth]{age.png}} \\
\hline
{\begin{tabularx}{\linewidth}{|X|X|}
\hline
status-fu & --- \\
count & 356 \\
unique & 2 \\
top & False \\
freq & 297 \\
\hline
\end{tabularx}} & \frame{\includegraphics[width=\linewidth]{status_fu.png}} \\
\hline
\end{tabularx}
\end{document}
The Output lools like this:
I want the Sub-tables on the left to be center top aligned with the Images on the right.
Any help???
Cheers!

align values in latex

i have a problem in LaTeX. I want the accuracy value centered in its cell since it is not associated with the labels but I don't know how to do it.
Here the code I'm using:
\documentclass[12 pt, letterpaper, twoside, openright]{book}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{enumitem}
\usepackage{booktabs, makecell, longtable}
\usepackage{stackengine}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{table}[H]
\caption {Logistic Regression and Random Forest Performances}
\centering
\begin{tabular}{llssssssss}
\toprule
\multirow{2}{*}{Patient} &\multirow{2}{*}{Labels} &
\multicolumn{4}{c}{Logistic Regression} &
\multicolumn{4}{c}{Random Forest} \\
&& {Accuracy (\%)}&{$Prec$} & {$Rec$} & {$F1$} & {Accuracy (\%)}& {$Prec$} & {$Prec$} & {$F1$} \\
\midrule
\multirow{2}{3em}{F0110} & 0 & 55 & 0.59 & 0.62 & 0.61 & 55& 0.70 & 0.76 & 0.72 \\
& 1 & & 0.58 & 0.55 & 0.57& & 0.72 & 0.66 & 0.69 \\
\hline
\bottomrule
\end{tabular}
\label{tab:tab1}
\end{table}
\end{document}
you can use the same \multirow command as with the "FO110" cell
\documentclass[12 pt, letterpaper, twoside, openright]{book}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{enumitem}
\usepackage{booktabs, makecell, longtable}
\usepackage{stackengine}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{table}[ht]
\caption {Logistic Regression and Random Forest Performances}
\centering
\begin{tabular}{llcccccccc}
\toprule
\multirow{2}{*}{Patient} &\multirow{2}{*}{Labels} &
\multicolumn{4}{c}{Logistic Regression} &
\multicolumn{4}{c}{Random Forest} \\
&& {Accuracy (\%)}&{$Prec$} & {$Rec$} & {$F1$} & {Accuracy (\%)}& {$Prec$} & {$Prec$} & {$F1$} \\
\midrule
\multirow{2}{3em}{F0110} & 0 & \multirow{2}{1em}{55} & 0.59 & 0.62 & 0.61 & \multirow{2}{1em}{55}& 0.70 & 0.76 & 0.72 \\
& 1 & & 0.58 & 0.55 & 0.57& & 0.72 & 0.66 & 0.69 \\
\hline
\bottomrule
\end{tabular}
\label{tab:tab1}
\end{table}
\end{document}
As said in your previous post, the tabularray packages makes merging cells much easier:
\documentclass[12 pt, letterpaper, twoside, openright]{book}
\usepackage{float}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{table}[H]
\caption{Logistic Regression and Random Forest Performances}
\centering
\begin{tblr}{llcccccccc}
\toprule
\SetCell[r=2]{} Patient &
\SetCell[r=2]{} Labels &
\SetCell[c=4]{} Logistic Regression &&&&
\SetCell[c=4]{} Random Forest &&& \\
&& {Accuracy (\%)}&{$Prec$} & {$Rec$} & {$F1$} & {Accuracy (\%)}& {$Prec$} & {$Prec$} & {$F1$} \\
\midrule
\SetCell[r=2]{} F0110 & 0 & \SetCell[r=2]{}55 & 0.59 & 0.62 & 0.61 & \SetCell[r=2]{}55& 0.70 & 0.76 & 0.72 \\
& 1 & & 0.58 & 0.55 & 0.57& & 0.72 & 0.66 & 0.69 \\
\bottomrule
\end{tblr}
\label{tab:tab1}
\end{table}
\end{document}

latex: color one column

I would like to create a table like the following:
in which only one column has a color and the color is applied to alternate rows.
The basic table would be:
\documentclass{article}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{float}
\usepackage[margin=2cm,left=2.5cm,includefoot]{geometry}
\begin{document}
\begin{table}[!h]
\centering
\caption{HS Sections}
\begin{tabular}{ccc}
& node & degree \\
\hline
& 1 & 1 \\
& 2 & 2 \\
& 3 & 2 \\
& 4 & 4 \\
& 5 & 2 \\
& 6 & 2 \\
& 7 & 1 \\
\hline
\end{tabular}
\label{tab:Table}
\end{table}
\end{document}
You could either manually use \cellcolor{...} to colour the cells you want or you could cheat a bit by colouring the whole rows in alternate colours and then overpaint the cells of the first column with white:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{float}
\usepackage[margin=2cm,left=2.5cm,includefoot]{geometry}
\begin{document}
\begin{table}[!h]
\centering
\caption{HS Sections}
\rowcolors{2}{cyan!50}{white}
\begin{tabular}{>{\cellcolor{white}}cc}
node & degree \\
\hline
1 & 1 \\
2 & 2 \\
3 & 2 \\
4 & 4 \\
5 & 2 \\
6 & 2 \\
7 & 1 \\
\hline
\end{tabular}
\label{tab:Table}
\end{table}
\end{document}

Alternative to Bordermatrix for MathJax

I'm using bordermatrix to write matrix with coefficient on the top and on the left:
I would like to display a similar matrix on my website where I use Mathjax but I get a [Math Processing Error]. Do you have a MathJax-alternative to bordermatrix to get the same result?
You can use the following construction:
\begin{align}
f(x) &= ax^2 + bx + c \\
&= \begin{array}{c c}
& \begin{array} {#{} c c c #{}}
u_1 & \cdots & u_q
\end{array} \\
\begin{array}{c}
e_1 \\ \vdots \\ e_n
\end{array}\hspace{-1em} &
\left(
\begin{array}{#{} c c c #{}}
u_{11} & \cdots & u_{1q} \\
\vdots & & \vdots \\
u_{n1} & \cdots & u_{nq}
\end{array}
\right) \\
\mbox{} % Blank line to match column names so as to align the = vertically
\end{array} \\[-12pt] % Correction for blank line
&= ax^2 + bx + c
\end{align}
Depending on whether you're aligning it with other content, you might not need the vertical adjustment I inserted.
Tested on Math.SE.

Wrong column spacing due to multicolumn in latex

in the LaTeX table below, the third column gets too way much spacing due to the long \multicolumn cell in the last line. Can anyone think of a way of getting LaTeX to distribute the additional spacing needed evenly across columns?
\documentclass[11pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{lrrr}
\toprule
& ICE-GB & ICE-SING & ICE-EA \\
\midrule
NP & 619 & 595 & 496 \\
\textbf{Arithmetic mean}& \textbf{1.36} & \textbf{1.33} & \textbf{1.22} \\
SD&0.73 & 0.71 & 0.53 \\
Variation coefficient& 0.54 & 0.52 & 0.44 \\
\midrule
Kruskal Wallis rank sum test&\multicolumn{3}{l}{$H = 16.3941, df = 2, p= 0.0002755123$} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Thanks!
Excess width \multicolumns end up assigning the excess to the last column. You can avoid this by either using a fixed-width \multicolumn - that is, use a p{<len>} column, or for even spreading of columns use a fixed-width column for the non-\multicolumn columns:
\documentclass[11pt]{article}
\usepackage{booktabs,array}
\begin{document}
\noindent
\begin{tabular}{l*{3}{>{\raggedleft\arraybackslash}p{5em}}}
\toprule
& ICE-GB & ICE-SING & ICE-EA \\
\midrule
NP & 619 & 595 & 496 \\
\textbf{Arithmetic mean} & \textbf{1.36} & \textbf{1.33} & \textbf{1.22} \\
SD & 0.73 & 0.71 & 0.53 \\
Variation coefficient & 0.54 & 0.52 & 0.44 \\
\midrule
Kruskal Wallis rank sum test & \multicolumn{3}{r}{$H = 16.3941, df = 2, p= 0.0002755123$} \\
\bottomrule
\end{tabular}
\end{document}
In the above example, the last three columns each have width 5em, and are \raggedleft (similar to an r-column specification).

Resources