表格宽度问题

表格宽度问题

我使用以下代码生成表格,但遇到了附图中所示的问题。有什么解决办法吗?

\documentclass[11pt,journal,compsoc]{IEEEtran}
\usepackage{filecontents}
\usepackage [noadjust]{cite}
\usepackage{caption}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{enumitem}

\usepackage{multirow}
\usepackage{booktabs}

\usepackage{array}
\usepackage{graphicx}
\usepackage{lipsum}

%
\ifCLASSOPTIONcompsoc
  % IEEE Computer Society needs nocompress option
  % requires cite.sty v4.0 or later (November 2003)
 % \usepackage[nocompress]{cite}
\else
  % normal IEEE
  %\usepackage{cite}
\fi




% *** GRAPHICS RELATED PACKAGES ***
%
\ifCLASSINFOpdf
  % \usepackage[pdftex]{graphicx}
  % declare the path(s) where your graphic files are
  % \graphicspath{{../pdf/}{../jpeg/}}
  % and their extensions so you won't have to specify these with
  % every instance of \includegraphics
  % \DeclareGraphicsExtensions{.pdf,.jpeg,.png}
\else
  % or other class option (dvipsone, dvipdf, if not using dvips). graphicx
  % will default to the driver specified in the system graphics.cfg if no
  % driver is specified.
  % \usepackage[dvips]{graphicx}
  % declare the path(s) where your graphic files are
  % \graphicspath{{../eps/}}
  % and their extensions so you won't have to specify these with
  % every instance of \includegraphics
  % \DeclareGraphicsExtensions{.eps}
\fi


\newcommand\MYhyperrefoptions{bookmarks=true,bookmarksnumbered=true,
pdfpagemode={UseOutlines},plainpages=false,pdfpagelabels=true,
colorlinks=true,linkcolor={black},citecolor={black},urlcolor={black},
pdftitle={Bare Demo of IEEEtran.cls for Computer Society Journals},%<!CHANGE!
pdfsubject={Typesetting},%<!CHANGE!
pdfauthor={Michael D. Shell},%<!CHANGE!
pdfkeywords={Computer Society, IEEEtran, journal, LaTeX, paper,
             template}}%<^!CHANGE!




\begin{document}

    \begin{table*}[t]
    \begin{tabular}{|c|c|c|c|c|c|c|c|}
    \hline 
    Study ID & Study title & First author name  & Year & Source  & Usability Factors & Development Area  & No, of Citation \\ 
    \hline 
    S1 & Persuasion for stronger passwords: Motivation and pilot study & Alain Forget & 2008 & ACM & Memorability and  efficiency & User Authentication & 26 \\ 
    \hline 
    S2 & VibraPass - Secure Authentication Based on Shared Lies   & Alexander De Luca & 2008 & ACM & Memorability and easy to use  & User Authentication & 52 \\ 
    \hline 
    \end{tabular} 


\end{document} 

在此处输入图片描述

答案1

减少(改善)表格宽度的两种主要方法:

使用p{...}列或C{...}具有新列类型(垂直和水平居中)的列。

有些行没有换行,因为我在那里没有使用连字符。

水平和垂直线不会提高表格的可读性,但这不是这里的问题......

\documentclass{article}

\usepackage{array}



\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}



\begin{table*}[t]
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline 
Study ID & Study title & First author name  & Year & Source  & Usability Factors & Development Area  & No, of Citation \\ 
\hline 
S1 & Persuasion for stronger passwords: Motivation and pilot study & Alain Forget & 2008 & ACM & Memorability and  efficiency & User Authentication & 26 \\ 
\hline 
S2 & VibraPass - Secure Authentication Based on Shared Lies   & Alexander De Luca & 2008 & ACM & Memorability and easy to use  & User Authentication & 52 \\ 
\hline 
\end{tabular} 
\end{table*}


\begin{table*}[t]
\begin{tabular}{|C{1cm}|C{3cm}|C{1.5cm}|*{2}{C{1.0cm}|}C{1.5cm}|C{1.5cm}|C{1.0cm}|}
\hline 
Study ID & Study title & First author name  & Year & Source  & Usability Factors & Develop-ment Area  & No, of Citation \\ 
\hline 
S1 & Persuasion for stronger passwords: Motivation and pilot study & Alain Forget & 2008 & ACM & Memorability and  efficiency & User Authentication & 26 \\ 
\hline 
S2 & VibraPass - Secure Authentication Based on Shared Lies   & Alexander De Luca & 2008 & ACM & Memorability and easy to use  & User Authentication & 52 \\ 
\hline 
\end{tabular} 
\end{table*}


\begin{table*}[t]
\begin{tabular}{|p{1cm}|p{3cm}|p{1.5cm}|*{2}{p{1.0cm}|}p{1.5cm}|p{1.5cm}|p{1.0cm}|}
\hline 
Study ID & Study title & First author name  & Year & Source  & Usability Factors & Develop-ment Area  & No, of Citation \\ 
\hline 
S1 & Persuasion for stronger passwords: Motivation and pilot study & Alain Forget & 2008 & ACM & Memorability and  efficiency & User Authentication & 26 \\ 
\hline 
S2 & VibraPass - Secure Authentication Based on Shared Lies   & Alexander De Luca & 2008 & ACM & Memorability and easy to use  & User Authentication & 52 \\ 
\hline 
\end{tabular} 
\end{table*}


\end{document}

在此处输入图片描述

答案2

此版本利用了booktabstabularxarray

  • array用于定义一些新列类型的命令。
    • C{width}定义宽度为 的居中列width
  • tabularx用于充分利用表格的全部宽度。
    • R是一个“可扩展”的列(类似X),但具有\raggedright对齐功能。
  • booktabs用于更好的规则和更好的间距。
    • 按照标准建议,删除了列之间的垂直线。booktabs有关详细信息,请参阅文档。

请注意,使用caption是有问题的:如果与此类一起使用,它会发出不应该使用的警告!

\documentclass[11pt,journal,compsoc]{IEEEtran}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}

\newcolumntype{R}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}

  \begin{table*}[t]
    \begin{tabularx}{\linewidth}{cRC{.1\linewidth}*{2}{c}*{2}{C{.125\linewidth}}C{.065\linewidth}}
      \toprule
      Study ID & \multicolumn{1}{c}{Study title} & First author name  & Year & Source  & Usability  Factors & Development Area & No, of Citation \\
      \midrule
      S1 & Persuasion for stronger passwords: Motivation and pilot study & Alain Forget & 2008 & ACM & Memorability and  efficiency & User Authentication & 26 \\
      \cmidrule(lr){1-8}
      S2 & VibraPass - Secure Authentication Based on Shared Lies   & Alexander De Luca & 2008 & ACM & Memorability and easy to use  & User Authentication & 52 \\
      \bottomrule
    \end{tabularx}
  \end{table*}

\end{document}

调整表格

答案3

使用和 的解决方案\makecelltabularxcellspace

\documentclass[11pt,journal,compsoc]{IEEEtran}
\usepackage{filecontents}
\usepackage [noadjust]{cite}
\usepackage{caption}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{enumitem}

\usepackage{multirow}
\usepackage{booktabs}

\usepackage{array}
\usepackage{graphicx}
\usepackage{lipsum}

%
\ifCLASSOPTIONcompsoc
% IEEE Computer Society needs nocompress option
% requires cite.sty v4.0 or later (November 2003)
% \usepackage[nocompress]{cite}
\else
% normal IEEE
%\usepackage{cite}
\fi




% *** GRAPHICS RELATED PACKAGES ***
%
\ifCLASSINFOpdf
% \usepackage[pdftex]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../pdf/}{../jpeg/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
% \DeclareGraphicsExtensions{.pdf,.jpeg,.png}
\else
% or other class option (dvipsone, dvipdf, if not using dvips). graphicx
% will default to the driver specified in the system graphics.cfg if no
% driver is specified.
% \usepackage[dvips]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../eps/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
% \DeclareGraphicsExtensions{.eps}
\fi


\newcommand\MYhyperrefoptions{bookmarks=true,bookmarksnumbered=true,
pdfpagemode={UseOutlines},plainpages=false,pdfpagelabels=true,
colorlinks=true,linkcolor={black},citecolor={black},urlcolor={black},
pdftitle={Bare Demo of IEEEtran.cls for Computer Society Journals},%<!CHANGE!
pdfsubject={Typesetting},%<!CHANGE!
pdfauthor={Michael D. Shell},%<!CHANGE!
pdfkeywords={Computer Society, IEEEtran, journal, LaTeX, paper,
         template}}%<^!CHANGE!
\usepackage{makecell}
\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\addparagraphcolumntypes{X}
\usepackage{ragged2e}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}m{#1}}

\begin{document}

\begin{table*}[t]\setlength\tabcolsep{5pt}
\begin{tabularx}{\linewidth}{|c|S{X}|c|c|c|X|c|c|}
\hline
\thead{Study\\ ID} & \thead{Study title} & \thead{First author name} & \thead{Year} & \thead{Source} & \thead{Usability Factors} & \thead{Development Area} & \thead{No of \\ Citation} \\
\hline
S1 & Persuasion for stronger passwords: Motivation and pilot study & Alain Forget & 2008 & ACM & Memorability and efficiency & User Authentication & 26 \\
\hline
S2 & VibraPass -- Secure Authentication Based on Shared Lies & Alexander De Luca & 2008 & ACM & Memorability and easy to use & User Authentication & 52 \\
\hline
\end{tabularx}
\end{table*}
\end{document} 

在此处输入图片描述

相关内容