LaTeX table too wide, how can I make it fit? - latex

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage[left=0.60in, right=0.60in, top=0.65in, bottom=0.65in, footskip=0.1in]{geometry}
\title{Peergrade 1}
\author{anonymous}
\date{September 2020}
\begin{document}
\maketitle
\section{Exercise 1}
\begin{tiny}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|}
\hline
A & B & C & A -\textgreater B & B -\textgreater $\sim$C & A -\textgreater $\sim$C & C -\textgreater $\sim$A & (A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A) & (B -\textgreater $\sim$C) -\textgreater ((A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A)) & Prop 1 \\ \hline
T & T & T & T & F & F & F & F & T & T \\ \hline
T & T & F & T & T & T & T & T & T & T \\ \hline
T & F & T & F & F & F & F & F & T & T \\ \hline
T & F & F & F & T & T & T & T & T & T \\ \hline
F & T & T & T & F & T & T & T & T & T \\ \hline
F & T & F & T & T & T & T & T & T & T \\ \hline
F & F & T & T & F & T & T & T & T & T \\ \hline
F & F & F & T & T & T & T & T & T & T \\ \hline
\end{tabular}
\end{table}
\end{tiny}
\end{document}
Can anyone help me so that the table fits in LaTeX? It almost fits, but half of the last column part goes outiside the paper. I have already tried to add /small and /footnotesize, but it doesnt work.

Please have a look at http://betterposters.blogspot.de/2012/08/the-data-prison.html how to design nice looking tables
You could use a tabularx and let latex adjust the size:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage[left=0.60in, right=0.60in, top=0.65in, bottom=0.65in, footskip=0.1in]{geometry}
\usepackage{tabularx}
\title{Peergrade 1}
\author{anonymous}
\date{September 2020}
\begin{document}
\maketitle
\section{Exercise 1}
\begin{tiny}
\begin{table}[h]
\begin{tabularx}{\linewidth}{|l|l|l|l|l|l|l|l|X|l|}
\hline
A & B & C & A -\textgreater B & B -\textgreater $\sim$C & A -\textgreater $\sim$C & C -\textgreater $\sim$A & (A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A) & (B -\textgreater $\sim$C) -\textgreater ((A -\textgreater $\sim$C) /\textbackslash (C -\textgreater $\sim$A)) & Prop 1 \\ \hline
T & T & T & T & F & F & F & F & T & T \\ \hline
T & T & F & T & T & T & T & T & T & T \\ \hline
T & F & T & F & F & F & F & F & T & T \\ \hline
T & F & F & F & T & T & T & T & T & T \\ \hline
F & T & T & T & F & T & T & T & T & T \\ \hline
F & T & F & T & T & T & T & T & T & T \\ \hline
F & F & T & T & F & T & T & T & T & T \\ \hline
F & F & F & T & T & T & T & T & T & T \\ \hline
\end{tabularx}
\end{table}
\end{tiny}
\end{document}

Just complementing the answer, if the table is very large, it's possible to rotate the sheet by using pdflscape:
\usepackage{pdflscape}
...
\begin{landscape}
(Your Table)
\end{landscape}

My solution:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{proof}
\usepackage[left=0.60in, right=0.60in, top=0.65in, bottom=0.65in, footskip=0.1in]{geometry}
\title{Peergrade 1}
\author{anonymous}
\date{September 2020}
\begin{document}
\maketitle
\section{Exercise 1}
%\begin{tiny}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|l|l|p{20mm}|p{22mm}|l|}
\hline
A & B & C & A -\textgreater B & B -\textgreater $\sim$C %
& A -\textgreater $\sim$C & C -\textgreater $\sim$A %
& (A -\textgreater $\sim$C) \par /\textbackslash (C -\textgreater $\sim$A) %
& (B -\textgreater $\sim$C) \par -\textgreater ((A -\textgreater $\sim$C) \par %
/\textbackslash (C -\textgreater $\sim$A)) & Prop 1 \\ \hline
T & T & T & T & F & F & F & F & T & T \\ \hline
T & T & F & T & T & T & T & T & T & T \\ \hline
T & F & T & F & F & F & F & F & T & T \\ \hline
T & F & F & F & T & T & T & T & T & T \\ \hline
F & T & T & T & F & T & T & T & T & T \\ \hline
F & T & F & T & T & T & T & T & T & T \\ \hline
F & F & T & T & F & T & T & T & T & T \\ \hline
F & F & F & T & T & T & T & T & T & T \\ \hline
\end{tabular}
\end{table}
%\end{tiny}
\end{document}
I have only edited the alignment of the 8th and 9th column (p{20mm}|p{22mm}) and added three \par in the first cell in such columns (out of dollar signs, you're typing text in the cells).
Anyway the solution with tabularx by #samcarter is very good.

Related

Centered Cells in Latex

Hello I'm trying to use cells in latex.
image of my cell here
How do you put the "Func2" and the "-" centered in the cell?
The code I'm using is:
\begin{tabularx}{0.8\textwidth} {
| >{\raggedright\arraybackslash}X
| >{\centering\arraybackslash}X
| >{\raggedleft\arraybackslash}X | }
\hline
\multicolumn{3}{|c|}{2D - $L = 64$} \\
\hline
Speedup(x) & Func1 & Func2 \\
\hline
Func2 & 35.4 & - \\
\hline
Func3 & 322.8 & 9.1 \\
\hline
\end{tabularx}
You could use the tabularray package. This makes it easy to change the alignment for individual cells:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
width={0.8\textwidth},
colspec={|X|X[halign=c]|X[halign=r]|}
}
\hline
\SetCell[c=3]{halign=c} 2D - $L = 64$ \\
\hline
Speedup(x) & Func1 & \SetCell{halign=c} Func2 \\
\hline
Func2 & 35.4 & \SetCell{halign=c} - \\
\hline
Func3 & 322.8 & 9.1 \\
\hline
\end{tblr}
\end{document}

Brackets around a very tall matrix

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent
A =
\bigg[
\begin{smallmatrix}
1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&0&0 \\
0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&0 \\
0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0 \\
0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0 \\
0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0 \\
0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0 \\
0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0 \\
0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0 \\
0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0 \\
0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0 \\
0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0 \\
0&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0 \\
0&0&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1 \\
\end{smallmatrix}
\bigg]
\noindent
You can use the tabularray package with its math library:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\begin{document}
\[
A =
\begin{+bmatrix}
1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&0&0 \\
0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&0 \\
0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0 \\
0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0 \\
0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0 \\
0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0 \\
0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0 \\
0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0 \\
0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0 \\
0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0&0 \\
0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0&0 \\
0&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1&0 \\
0&0&0&0&0&0&0&0&0&0&0&0&1&0&0&0&0&0&0&0&0&0&0&1 \\
\end{+bmatrix}
\]
\end{document}

align ! missing } inserted

I am trying to typeset the following equation in the align-evoirement
\begin{align}
t_2' &= t_2 + \frac{L/C} \\
t_1' &= t_1 + \frac{L + v\Delta t\cos\theta}{c} \\
t_2' - t_1' &= (t_2-t_1) + \frac{L-L-v\Delta t\cos\theta}{C} \\
\Delta t' &= \Delta t - \frac{v\Delta t \cos \theta}{c} \\
\Delta t' &= \Delta t \left(1-\frac{v\cos\theta}{c}\right) \\
\frac{1}{\nu} &= \frac{1}{\nu_0 \sqrt{1-\frac{v^2}{c^2}}}~\left(1-\frac{v\cos \theta {c}\right) \\
\nu &= \nu_0\frac{ \sqrt{1-\dfrac{v^2}{c^2}}}{1-\dfrac{v\cos \theta }{c}}
\end{align}
But when I tried this I got the following message:
[45]
! Missing } inserted.
<inserted text>
}
l.938 \end{align}
?
I copied the equations in Matcha (without the &), where it was perfectly working... I tried some things, but those did not seem to work...
Does anybody know what I did wrong?
At two occasions you write \frac{..} without the mandatary second argument. You must write \frac{...}{...} instead.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
t_2' &= t_2 + \frac{L}{C} \\
t_1' &= t_1 + \frac{L + v\Delta t\cos\theta}{c} \\
t_2' - t_1' &= (t_2-t_1) + \frac{L-L-v\Delta t\cos\theta}{C} \\
\Delta t' &= \Delta t - \frac{v\Delta t \cos \theta}{c} \\
\Delta t' &= \Delta t \left(1-\frac{v\cos\theta}{c}\right) \\
\frac{1}{\nu} &= \frac{1}{\nu_0 \sqrt{1-\frac{v^2}{c^2}}}~\left(1-\frac{v\cos \theta}{c}\right) \\
\nu &= \nu_0\frac{ \sqrt{1-\dfrac{v^2}{c^2}}}{1-\dfrac{v\cos \theta }{c}}
\end{align}
\end{document}

Specific table in Latex

I'm trying to get table like this:
but it's not looking such good, my code is
\begin{center}
\begin{tabular}{ c c c c }
& & \textbf{Sferyczne} & \textbf{KartezjaƄskie} \\
$l=0$ & $y^{0}_{0}(\theta,\phi)=$ & $\sqrt{\frac{1}{4\pi}}$ & $\sqrt{\frac{1}{4\pi}}$ \\
$l=1$ & \begin{dcases} $y^{-1}_{1}(\theta,\phi)=$ \\ $y^{0}_{1}(\theta,\phi)=$ \\ $y^{1}_{1}(\theta,\phi)=$ \end{dcases} & \begin{tabular}{c} $\sqrt{\frac{3}{4\pi}}\cos\phi\sin\theta$ \\ g \\ g \end{tabular} & \begin{tabular}{c} $\sqrt{\frac{3}{4\pi}}x$ \end{tabular} \\
cell10 & cell11 & cell12
\end{tabular}
\end{center}
and there is how it looks:
Please help me to get the same table like on first picture.
Here is one way to achieve the output you desire:
\documentclass{article}
\usepackage{xparse,eqparbox,amsmath}
% https://tex.stackexchange.com/a/34412/5764
\makeatletter
\NewDocumentCommand{\eqmathbox}{o O{c} m}{%
\IfValueTF{#1}
{\def\eqmathbox###1##2{\eqmakebox[#1][#2]{$##1##2$}}}
{\def\eqmathbox###1##2{\eqmakebox{$##1##2$}}}
\mathpalette\eqmathbox#{#3}
}
\makeatother
\newcommand{\ts}{\quad}
\begin{document}
\[
\renewcommand{\arraystretch}{2.5}
\begin{array}{ r r }
& \eqmakebox[c1]{} \ts
\eqmakebox[c2][c]{\textbf{Spherical}} \ts
\eqmakebox[c3][c]{\textbf{Cartesian}} \\
l = 0 & \eqmathbox[c1][r]{y_0^0(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{1}{4 \pi}}} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{1}{4 \pi}},} \\
l = 1 & \left\{\begin{array}{ #{} r #{} }
\eqmathbox[c1][r]{y_1^{-1}(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{3}{4 \pi}} \sin \phi \sin \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{3}{4 \pi}} x,} \\
\eqmathbox[c1][r]{y_1^0(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{3}{4 \pi}} \cos \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{3}{4 \pi}} z,} \\
\eqmathbox[c1][r]{y_1^1(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{3}{4 \pi}} \cos \phi \sin \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{3}{4 \pi}} y,}
\end{array}\right.\kern-\nulldelimiterspace \\
l = 2 & \left\{\begin{array}{ #{} r #{} }
\eqmathbox[c1][r]{y_2^{-2}(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{15}{4 \pi}} \sin \phi \cos \phi \sin^2 \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{15}{4 \pi}} x y,} \\
\eqmathbox[c1][r]{y_2^{-1}(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{15}{4 \pi}} \sin \phi \sin \theta \cos \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{15}{4 \pi}} y z,} \\
\eqmathbox[c1][r]{y_2^0(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{5}{16 \pi}} (3 \cos^2 \theta - 1)} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{5}{16 \pi}} (3 z^2 - 1),} \\
\eqmathbox[c1][r]{y_2^1(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{15}{4 \pi}} \cos \phi \sin \theta \cos \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{15}{8 \pi}} x z,} \\
\eqmathbox[c1][r]{y_2^2(\theta, \phi) =} \ts
\eqmathbox[c2][l]{\sqrt{\dfrac{15}{16 \pi}} (\cos^2 \phi - \sin^2 \phi) \sin^2 \theta} \ts
\eqmathbox[c3][l]{\sqrt{\dfrac{15}{32 \pi}} (x^2 - y^2).}
\end{array}\right.\kern-\nulldelimiterspace \\
& \eqmakebox[c1]{} \ts
\eqmakebox[c2][c]{\textbf{Spherical}} \ts
\eqmakebox[c3][c]{\textbf{Cartesian}}
\end{array}
\]
\end{document}
The approach uses boxes to fake a columnar alignment. The outer array contains only two right-aligned columns, the first for the l = ? construction, and the second for the rest. Each element within the second column is set inside a box (using either \eqmakebox or \eqmathbox) with a tag: \eq..box[<tag>][<align>]{<stuff>}. Each box with the same <tag> will have the same, maximum width and you can specify the individual box <align>ment.
You can vary the number in \arraystretch to increase the vertical height of the entire construction. Also, \ts is inserted to represent a tabular separation, defaulting to a space of 1em (or \quad). You can change this to (say) \hspace{2cm} to insert a larger horizontal gap between the columns.

How to create paper used notation in Latex?

How to use Latex to create a notation style like this image. or any other suggestions ?
\documentclass{article}
% See http://tex.stackexchange.com/questions/112576/math-mode-in-tabular-without-having-to-use-everywhere
\usepackage{amstext}
\usepackage{array}
\usepackage{amssymb}
\newcolumntype{L}{>{$}l<{$}}
\begin{document}
\textbf{Typing rules for F$_1$}
\begin{tabular}{LLL}
\hline
\text{\footnotesize(Env $\varnothing$)} &
\text{\footnotesize(Env $x$)}\\
\frac{}{\varnothing \vdash \diamond} &
\frac{E \vdash A \quad x \notin dom(E)}{E, x:A \vdash \diamond} \\
&&\\
\text{\footnotesize(Type Const} &
\text{\footnotesize(Type Arrow)}\\
\frac{E \vdash \diamond}{E \vdash K} &
\frac{E \vdash A \quad E \vdash B}{E \vdash A \rightarrow B} \\
&&\\
\text{\footnotesize(Val $x$)} &
\text{\footnotesize(Val Fun)} &
\text{\footnotesize(Val Appl)} \\
\frac{E\vdash \diamond}{E \vdash x :E(x)} &
\frac{E,x:A\vdash b:B}{E \vdash \lambda(x:A)b :A \rightarrow B} &
\frac{E \vdash b:A \rightarrow B \quad E \vdash a : A}{E \vdash b(a) : B} \\
\hline
\end{tabular}
\end{document}

Resources