Graphics, Figures & TablesHow to make my table prettier?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yaozhao
Posts: 57
Joined: Sat Oct 27, 2018 10:38 pm

How to make my table prettier?

Post by yaozhao »

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{center}
\begin{tabular}{ |c|c|c| } 
\hline
 {} &  \multicolumn{2}{|c|}{Decision Conclusion from hypothesis test)} \\
 \hline
 True Population State (Unknown) & Reject $H_0$ & Retain $H_0$ \\  
 \hline
 Means are equal ($H_0$ is true) & Incorrect decision: Type I error & Correct decision    \\
 \hline
 Means are unequal ($H_0$ is false) & Correct decision  & Incorrect decision: Type II error   \\
\hline
\end{tabular}
\end{center}
I don't wanna Incorrect decision: Type I error. Instead, I want
Incorrect decision:
Type I error

But it's still in one cell.

Many thanks in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

How to make my table prettier?

Post by mas »

The 'c' column specifier will not wrap long lines of text. You have to break it manually and put the extra text on the next row. Alternately, you can use the 'p' column specifier and get better results.

Since your question is bout getting a 'prettier table, as is commonly suggested, avoid using both horizontal and vertical lines in a table. I am attaching my attempt:

Code: Select all

\documentclass{article}    
\usepackage[utf8]{inputenc}    
\usepackage{booktabs}    
\begin{document}    
\begin{center}    
\renewcommand{\arraystretch}{1.3}    
\begin{tabular}{ lp{1.5in}p{1.5in} }    
\toprule    
 {} &  \multicolumn{2}{c}{Decision Conclusion from hypothesis test)} \\    
 \midrule    
 True Population State (Unknown) & Reject $H_0$ & Retain $H_0$ \\    

 Means are equal ($H_0$ is true) & Incorrect decision:\par Type I error & Correct decision      |-> \\        

 Means are unequal ($H_0$ is false) & Correct decision  & Incorrect    
 decision: \par Type II error   \\    
\toprule    
\end{tabular}    
\end{center}    
\end{document}
x.png
x.png (8.61 KiB) Viewed 3101 times

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

How to make my table prettier?

Post by Ijon Tichy »

Nice, but your example produces an overfull \hbox of 57.69922pt (you could add package showframe to visualize the overlapping). Here another example without overfull \hbox:
\documentclass{article}    
\usepackage[utf8]{inputenc}% Only needed for outdated LaTeX distributions  
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{ragged2e}
\begin{document}    
\begin{center}% Don't use this inside a table environment (instead use
              % \centering command)  
\renewcommand{\arraystretch}{1.3}    
\begin{tabularx}{\linewidth}{@{}l*{2}{>{\RaggedRight}X}@{}}
\toprule    
 {} &  \multicolumn{2}{>{\hsize=\dimexpr2\hsize+2\tabcolsep\RaggedRight}X}{Decision Conclusion from hypothesis (test)} \\    
 \midrule    
 True Population State (Unknown) & Reject $H_0$ & Retain $H_0$ \\    

 Means are equal ($H_0$ is true) & Incorrect decision:\par Type I error & Correct decision      |-> \\        

 Means are unequal ($H_0$ is false) & Correct decision  & Incorrect    
 decision: \par Type II error   \\    
\toprule    
\end{tabularx}    
\end{center}    
\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply