我的表格太宽了。如何让它适合文本块的宽度?

我的表格太宽了。如何让它适合文本块的宽度?
\begin{table*}    
\begin{center}   
\caption{Comparison of existing methods using infrared array sensor.}   
\begin{tabular}{c c c c c c c} \\ \toprule         
{Study} & {IR sensor (resolution)} & {No. of sensors} & {Position of the sensor} & {Methods} & {Accuracy} & {limitations} \\ \hline        
Mashiyama et al.\cite{Mashiyama_2014} & $8 \times 8$ & 1 & Ceiling & SVM & above 94\% & Very limited activity in small area, no transition of activity detection \\ \midrule        
Mashiyama et al.\cite{Mashiyama_2015_2} & $8\times 8$ & 1 & Ceiling & k-NN & 94\% & Less-effective feature extraction methods  \\ \midrule        
Kobayashi et al\cite{Kobayashi_2018} & $8\times 8$ & 2 & Ceiling, Wall & SVM & above 90\% & Particular positions difficult to differentiate the activity due reactive pixels \\ \midrule      
Xiyui  et al.\cite{Fan_2017} & $8\times 8$ & 1 & Wall & LSTM, GRU & 75\% and 85\% & Very limited perform only in parallel and perpendicular to the sensor     \\ \midrule        
Taniguchi et al.\cite{Taniguchi_2014} & $16\times 16$ & 2 & Ceiling, Wall & Time series analysis & 72\% & Old approach less accuracy \\ \midrule        
Taramasco et al.\cite{Taramasco_2018}& $1\times 16$ & 2 & Opposite corner of the room & LSTM, GRU, Bi-LSTM & 93\% & Its highly computation cost to implement to the devices  \\\bottomrule           
\end{tabular}\label{tabular_1}    
\end{center}
\end{table*}

下图中的表格与我想要实现的目标有些接近。

在此处输入图片描述

答案1

您需要允许换行全部七列,但c列类型不允许这样做。我建议您加载tabularx包并设置X允许改变相对列宽的包列类型的版本。请注意,在下面的示例中,7 列的相对宽度加起来为 7。我还会使用更少的\midrule指令;事实上,大多数指令都可以替换为\addlinespace

在此处输入图片描述

\documentclass{article}  % choose a suitable document class
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{booktabs,tabularx,ragged2e}
\newcolumntype{C}[1]{>{\Centering\hspace{0pt}\hsize=#1\hsize}X}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}\hsize=#1\hsize}X}

\begin{document}

\begin{table}     
\setlength\tabcolsep{4pt}
\caption{Comparison of existing methods using infrared array sensor.}   
\label{tab:comparison}
\begin{tabularx}{\textwidth}{@{} L{0.9} C{0.9}C{0.55}C{0.9}C{0.9}C{0.8} L{2.05} @{}} \\ 
\toprule         
Study & IR sensor (resolution) & No.\ of sensors & Position of sensor & Methods & Accuracy & Limitations \\ \midrule        
Mashiyama et al.\cite{Mashiyama_2014} & $8 \times 8$ & 1 & Ceiling & SVM & above 94\% & Very limited activity in small area, no transition of activity detection \\ 
\addlinespace %\midrule        
Mashiyama et al.\cite{Mashiyama_2015_2} & $8\times 8$ & 1 & Ceiling & k-NN & 94\% & Less-effective feature extraction methods  \\ 
\addlinespace %\midrule        
Kobayashi et al\cite{Kobayashi_2018} & $8\times 8$ & 2 & Ceiling, Wall & SVM & above 90\% & Particular positions difficult to differentiate the activity due reactive pixels \\ 
\addlinespace %\midrule      
Xiyui  et al.\cite{Fan_2017} & $8\times 8$ & 1 & Wall & LSTM, GRU & 75\% and 85\% & Very limited perform only in parallel and perpendicular to the sensor \\ 
\addlinespace %\midrule        
Taniguchi et al.\cite{Taniguchi_2014} & $16\times 16$ & 2 & Ceiling, Wall & Time series analysis & 72\% & Old approach less accuracy \\ 
\addlinespace %\midrule        
Taramasco et al.\cite{Taramasco_2018}& $1\times 16$ & 2 & Opposite corner of the room & LSTM, GRU, Bi-LSTM & 93\% & Its highly computation cost to implement to the devices  \\ 
\bottomrule           
\end{tabularx}    
\end{table}

\end{document}

答案2

使用该mdwtab包作为对@Mico 回答的补充(+1):

\documentclass[twocolumn]{article}  % choose a suitable document class
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{ragged2e}
\usepackage{mdwtab,tabularx} % <---
\newcolumntype{C}[1]{>{\Centering\hspace{0pt}\hsize=#1\hsize}X}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}\hsize=#1\hsize}X}
\usepackage{stfloats}
\usepackage{lipsum}
\begin{document}
    \begin{table*}[b]
\caption{Comparison of existing methods using infrared array sensor.}
\label{tabular_1}
    \centering
    \setlength\tabcolsep{4pt}
\begin{tabularx}{\linewidth}{@{} L{0.9} C{0.9}C{0.55}C{0.9}C{0.9}C{0.8} L{2.05} @{}}
    \hlx[1pt]{hv}       % <---
{Study} & {IR sensor (resolution)} & {No. of sensors} & {Position of the sensor} & {Methods} & {Accuracy} & {limitations} \\
    \hlx[0.5pt]{vhv}    % <---
Mashiyama et al.\cite{Mashiyama_2014} & $8 \times 8$ & 1 & Ceiling & SVM & above 94\% & Very limited activity in small area, no transition of activity detection \\
    \hlx{vhv}           % <---
Mashiyama et al.\cite{Mashiyama_2015_2} & $8\times 8$ & 1 & Ceiling & k-NN & 94\% & Less-effective feature extraction methods  \\
    \hlx{vhv}
Kobayashi et al\cite{Kobayashi_2018} & $8\times 8$ & 2 & Ceiling, Wall & SVM & above 90\% & Particular positions difficult to differentiate the activity due reactive pixels \\
    \hlx{vhv}
Xiyui  et al.\cite{Fan_2017} & $8\times 8$ & 1 & Wall & LSTM, GRU & 75\% and 85\% & Very limited perform only in parallel and perpendicular to the sensor     \\
    \hlx{vhv}
Taniguchi et al.\cite{Taniguchi_2014} & $16\times 16$ & 2 & Ceiling, Wall & Time series analysis & 72\% & Old approach less accuracy \\
        \hlx{vhv}
Taramasco et al.\cite{Taramasco_2018}& $1\times 16$ & 2 & Opposite corner of the room & LSTM, GRU, Bi-LSTM & 93\% & Its highly computation cost to implement to the devices  \\
    \hlx[1pt]{vh}       % <---
\end{tabularx}
    \end{table*}
\lipsum
\end{document}

在此处输入图片描述

相关内容