How to draw matrices with a label in a latex figure? - latex

I want to create tables as part of a figure in latex. I want to achieve this look:
I have no idea which package/commands to use.

Nothing fancy here; just some math as part of the figure environment:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.4\linewidth]{example-image}
\medskip
$\sigma_1 \rightarrow \sigma_2 :
\begin{array}{ | *{5}{c|} }
a & b & c & e & f \\
\hline
a & b & c & e & f
\end{array}$ \quad
$\sigma_1 \rightarrow \sigma_3 :
\begin{array}{ | *{5}{c|} }
a & b & c & e & f \\
\hline
a & b & c & \gg & f
\end{array}$
\caption{A figure caption}
\end{figure}
\end{document}

Related

Latex - Parentheses for sections in a table

I want to create a table like this:
Table with parentheses
But I don't know how to add the parentheses, here's my code:
\section{Table}
\subsection{Normal table}
\begin{center}
\begin{tabular}{ c c c }
& C & D \\
C & R & S \\
D & T & P \\
\end{tabular}
\end{center}
It looks like this:
My table
Many thanks!

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.

avoid latex table thicker line

I make a table like this one :
\documentclass[pdfa,sl,draft,english]{letter}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{table}
\begin{center}
\begin{threeparttable}
\caption{Table caption}
\begin{tabular}{ | c | c| c | c |}
\hline
a
& \multicolumn{1}{|p{3cm}|}{\centering b \\ (unit) }
& c ${}^{a}$
& d ${}^{b}$ \\ \hline
1 & 1b & 1c & 1d \\
2 & 2b & 2c & 2d \\ \hline
\end{tabular}
\begin{tablenotes}
\small
\item ${}^{a}$ Note for c column
\item ${}^{b}$ Note for d column
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{table}
\end{document}
The compilation make a thicker right line on the first column and first row. Do you have an idea to avoid this?
This works. It is a bit of a hack, but essentially you set the columns to a width that you predefine. It seems to look okay like this.
\documentclass[pdfa,sl,draft,english]{letter}
\usepackage[flushleft]{threeparttable}
\usepackage{makecell}
\newcolumntype{?}{!{\vrule width 0.1pt}}
\begin{document}
Table With Bold Line
\begin{tabular}{ | c | c | c | c |}
\hline
a
& \multicolumn{1}{|p{3cm}|}{\centering b \\ (unit) }
& c ${}^{a}$
& d ${}^{b}$ \\ \hline
1 & 1b & 1c & 1d \\
2 & 2b & 2c & 2d \\ \hline
\end{tabular}
Table Without Bold Line
\begin{tabular}{ ? c ? c ? c ? c ?}
\hline
a
& \multicolumn{1}{|p{3cm}|}{\centering b \\ (unit) }
& c ${}^{a}$
& d ${}^{b}$ \\ \hline
1 & 1b & 1c & 1d \\
2 & 2b & 2c & 2d \\ \hline
\end{tabular}
\end{document}

Latex table multiple row and multiple column

I'm trying to create a table in Latex but without success. I tried different solutions but no one solves my problem.
I would like create a table like the picture below:
Can anyone show how to do this in Latex please?
One first sketch may be the following:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multirow{3}{*}{A} & \multicolumn{2}{c|}{User B} & %
\multicolumn{2}{c|}{User C} & \multirow{3}{*}{D}\\
\cline{2-5}
& \multicolumn{2}{c|}{Value} & \multicolumn{2}{c|}{Value} & \\
\cline{2-5}
& B1 & B2 & C1 & C2 & \\
\hline
& & & & & \\
\hline
& & & & & \\
\hline
% etc. ...
\end{tabular}
\end{document}
It produces:
Addendum:
\documentclass{article}
\usepackage{multirow}
\begin{document}
{\sffamily %
\begin{tabular}{|c|c|c|c|c|c|c|}% seven columns now, not six...
\hline
\multirow{3}{*}{A} & \multicolumn{2}{c|}{User B} & \multirow{3}{*}{X} & %
\multicolumn{2}{c|}{User C} & \multirow{3}{*}{D}\\
\cline{2-3}\cline{5-6}
& \multicolumn{2}{c|}{Value} & & \multicolumn{2}{c|}{Value} & \\
\cline{2-3}\cline{5-6}
& B1 & B2 & & C1 & C2 & \\
\hline
& & & & & & \\
\hline
& & & & & & \\
\hline
% etc. ...
\end{tabular}
}%
\end{document}
produces:
Please, critically check all the differences between the original code and this latter.
Don't forget that several LaTeX packages can help you improving style, dimensions and spacing of your table: among these, I advise you to have a look at bigstrut.
Also:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{3}{*}{A} & \multirow{3}{*}{X} & \multicolumn{2}{c|}{User B} & \multicolumn{2}{c|}{User C} & \multirow{3}{*}{D}\\
\cline{3-6}
& & \multicolumn{2}{c|}{Value} & \multicolumn{2}{c|}{Value} & \\
\cline{3-6}
& & B1 & B2 & C1 & C2 & \\
\hline
& & & & & & \\
\hline
\end{tabular}
\end{document}
You should now be able to operate on your own further changes to the model of table.
Check out the multirow package:
http://texblog.org/2012/12/21/multi-column-and-multi-row-cells-in-latex-tables/
You have to include the library:
%multi-column
\multicolumn{number cols}{align}{text} % align: l,c,r
%multi-row
\usepackage{multirow}
\multirow{number rows}{width}{text}
Then it looks like this:
\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
\caption{Multi-column and multi-row table}
\begin{center}
\begin{tabular}{ccc}
\hline
\multicolumn{2}{c}{\multirow{2}{*}{Multi-col-row}}&X\\
\multicolumn{2}{c}{}&X\\
\hline
X&X&X\\
\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}
\end{document}
note: code examples from the link provided

Vertical align text to a box next to it

In the output below, I'm trying to align Author with the top of the box next to it. I've tried a couple of different boxes and whatnot, but I can't get it to align properly.
Here's the code:
\mbox{
Author
}
\fbox{\begin{minipage}[c]{12cm}
\medskip
$for(author)$
$author.name$\\$if(author.title)$\emph{$author.title$}\\$endif$$if(author.company)$$author.company$$endif$
\par\medskip
$endfor$
\medskip
\end{minipage}}
You should set the entire construction inside a tabular, and then also use a [t]op-aligned tabular for the framed box construction:
\documentclass{article}
\begin{document}
\begin{tabular}{l | l |}
\cline{2-2}
Author & \begin{tabular}[t]{#{}p{12cm}#{}}
Jack Appleseed \\
\emph{Marketing Manager} \\
Unimaginitive Solutions \\ \\
John Appleseed \\
\emph{Business Development Manager} \\
Unimaginitive Solutions \\
\end{tabular} \\
\cline{2-2}
\end{tabular}
\end{document}
I'm assuming you can use the following Pandoc construction (I haven't used Pandoc):
\begin{tabular}{l | l |}
\cline{2-2}
Author & \begin{tabular}[t]{#{}p{12cm}#{}}
$for(author)$
$author.name$ \\ $if(author.title)$\emph{$author.title$} \\ $endif$ $if(author.company)$ $author.company$ \\ $endif$
$endfor$
\end{tabular} \\
\cline{2-2}
\end{tabular}

Resources