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!
Related
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}
Using the wrapfig package with a table inside a section, the table's first row is not aligned with the text that wraps it. This problem is not present when working outside of a section.
\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\section{Section}
\begin{wraptable}{l}{0pt}
\begin{tabular}{cccc}
A & B & C & D \\
E & F & G & H\\
\end{tabular}
\label{Mytable}\caption{This is my table.}
\end{wraptable}
\textbf{This bit of text should be aligned with the table's top row.}
\lipsum[2]
\end{document}
What this gives is:
Whereas ideally I'd like to get something like:
You could try to adjust \intextsep:
\documentclass{article}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\section{Section}
{
\setlength\intextsep{-0.4ex}
\begin{wraptable}{l}{0pt}
\begin{tabular}{cccc}
A & B & C & D \\
E & F & G & H\\
\end{tabular}
\label{Mytable}\caption{This is my table.}
\end{wraptable}
\textbf{This bit of text should be aligned with the table's top row.}
\lipsum[2]
}
\end{document}
I am trying to center one of the columns in a table and It says I have an extra column. The table also doesnt look correct i.e.
What it looks like:
F(t) F(s)
u(t)
1/s
e 1/(s-a)
What I expect:
F(t) F(s)
u(t) 1/s
e 1/(s-a)
I think it is because I'm trying to insert an equation in the table but I'm not sure.
Here is the code
\documentclass[12pt, letterpaper, fleqn]{article}
\usepackage{array}
\begin{document}
\begin{table}
% \setlength{\tabcolsep}{6pt}
% \renewcommand{\arraystretch}{1}
\begin{tabular}{p{0.225\textwidth} >{\centering}p{0.15\textwidth}}
\textbf{F(t)} & \textbf{F(s)} \\
\(u(t)\) & \(\frac{1}{s}\) \\
\(e^{at}\) & \(\frac{1}{s-a}\) \\
\end{tabular}
\end{table}
\end{document}
Your use of \centering to centre the column works, but it screws up the way \\ is interpreted. A correction is included in the array package documentation after using alignment switches (like \centering, \raggedright, \raggedleft, etc) using \arraybackslash:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{ p{0.225\textwidth} >{\centering\arraybackslash}p{0.15\textwidth} }
$\mathbf{F(t)}$ & $\mathbf{F(s)}$ \\
$u(t)$ & $1 / s$ \\
$e^{at}$ & $1 / (s - a)$
\end{tabular}
\end{document}
If you remove >{\centering}, then your code should compile as expected. Post a comment otherwise! Do you want any column to have centered contents?
I am trying to create a table that has combination of single column and double columns rows? Any idea how can I do that in latex?
See Figure below:
You should set the tabular using the maximum number of columns, and then make some columns span \multicolumn:
\documentclass{article}
\usepackage{tabularx}
\usepackage[nopar]{lipsum}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{| X | X | X |}
\hline
& Abstract & Direct \\
\hline
Type A & \multicolumn{2}{ p{\dimexpr.6667\linewidth-2\tabcolsep} |}{\lipsum[1]} \\
\cline{2-3}
& A & B \\
\hline
Type B & \multicolumn{2}{ p{\dimexpr.6667\linewidth-2\tabcolsep} |}{\lipsum[2]} \\
\cline{2-3}
& A & B \\
\hline
\end{tabularx}
\end{document}
Ok so i wrote this simple code (shown below) to create an alternate colour table using \rowcolors, yet instead of just colouring the rows of the table it colours the whole row (even more than textwidth). Any help how to fix this?
begin{table}[ht]
\scriptsize
\begin{center}
\rowcolors{1}{lightgray}{white}
\caption{...}
\begin{tabular}{p{0.45\textwidth} | p{0.55\textwidth}}
Filename & Contents \\
\hline
\hline
A & B \\
C & F \\
\end{tabular}
\end{center}
\end{table}
While 0.45\textwidth + 0.55\textwidth would seem to fit within \textwidth, each of your p-columns have an extra column separation... on both sides. To that end, you should remove them in order to make it fit within the text block boundary:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{lipsum}
\begin{document}
\begin{table}[ht]
\scriptsize\centering
\rowcolors{1}{lightgray}{white}
\caption{This is a table.}
\begin{tabular}{
p{\dimexpr0.45\textwidth-2\tabcolsep} |
p{\dimexpr0.55\textwidth-2\tabcolsep}}
Filename & Contents \\
\hline
\hline
A & B \\
C & F
\end{tabular}
\end{table}
\lipsum[1]
\end{document}
Also, don't use the center environment; use \centering instead.