![调整“Longtable”中的列宽](https://linux22.com/image/370958/%E8%B0%83%E6%95%B4%E2%80%9CLongtable%E2%80%9D%E4%B8%AD%E7%9A%84%E5%88%97%E5%AE%BD.png)
如果这是一个简单的问题,请原谅,但是如何分隔下表中的列,以使文本不那么靠近?
\documentclass[a4paper,11pt]{article}
\usepackage{color}
\usepackage{graphicx, epstopdf}
\usepackage{gensymb}
\usepackage{times}
\usepackage{adjustbox}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{booktabs,caption, makecell}
\usepackage{pdflscape,afterpage,caption}
\usepackage[british]{babel}
\usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\usepackage[left=2.5cm, right=2.cm, top=2.5cm]{geometry}
\begin{document}
\pagenumbering{roman}
\newpage
\addcontentsline{toc}{section}{Abbreviations}
\section*{Abbreviations}
\begin{longtable}
\setlength\tabcolsep{60pt}
\centering
\small
% your table
\hspace*{-18mm}%
\vspace{-5.5mm}%
\begin{longtable}
\toprule
{Abbreviation}&{Explanation}\\[0.5 ex]
\midrule
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
\bottomrule
\end{longtable}%
\hspace*{-12mm}%
\vspace{50mm}
\label{table:ETD Raman}\\
\end{longtable}
\end{document}
我检查了每一行代码,更改了参数,但似乎无法移动文本。我附上了我的 MWE 和输出图片。
提前致谢!
答案1
你的例子有许多问题...
您正在使用
longtable
但您没有\usepackage{longtable}
;正如@Bernard 指出的那样,您不必(一定不能?)嵌套两个
longtable
环境。我将外部环境更改为table
;你的答案实际的问题是:删除
\setlength\tabcolsep{60pt}
。此行将每列的宽度增加120pt
;longtable
与任何其他表格环境(tabular
、等)一样tabularx
, 接受一个强制参数,即列描述符。我为您使用了居中列({c c}
);我删除了后面的换行符
\label{table:ETD Raman}
。您不需要使用
\centering
longtable。
\documentclass[a4paper,11pt]{article}
\usepackage{color}
\usepackage{graphicx, epstopdf}
\usepackage{gensymb}
\usepackage{times}
\usepackage{adjustbox}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{booktabs,caption, makecell}
\usepackage{pdflscape,afterpage,caption}
\usepackage[british]{babel}
% \usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\usepackage[left=2.5cm, right=2.cm, top=2.5cm]{geometry}
\begin{document}
\pagenumbering{roman}
\newpage
\addcontentsline{toc}{section}{Abbreviations}
\section*{Abbreviations}
% \begin{table}
% \setlength\tabcolsep{60pt}
% \centering
% your table
\hspace*{-18mm}%
\vspace{-5.5mm}%
{\small
\begin{longtable}{c c}
\toprule
{Abbreviation}&{Explanation}\\[0.5 ex]
\midrule
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
\bottomrule
\label{table:ETD Raman}
\end{longtable}%
\hspace*{-12mm}%
\vspace{50mm}
}
% \end{table}
\end{document}
答案2
更新:问题解决了!原来,这个问题是因为我将 longtable 嵌套到了 table 环境中(上面提到过,但当时我并不理解)。
我注释掉了引用表格环境的代码,现在它可以正常工作了。结果是表格分为两页,列间距适当。
\documentclass[a4paper,11pt]{article}
\usepackage{color}
\usepackage{graphicx, epstopdf}
\usepackage{gensymb}
\usepackage{times}
\usepackage{adjustbox}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{booktabs,caption, makecell}
\usepackage{pdflscape,afterpage,caption}
\usepackage[british]{babel}
% \usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\usepackage[left=2.5cm, right=2.cm, top=2.5cm]{geometry}
\begin{document}
\pagenumbering{roman}
\newpage
\addcontentsline{toc}{section}{Abbreviations}
\section*{Abbreviations}
%\begin{table}
% \setlength\tabcolsep{60pt}
% \centering
%\small
% your table
%\hspace*{-18mm}%
%\vspace{-5.5mm}%
\begin{longtable}{c c}
\toprule
{Abbreviation}&{Explanation}\\[0.5 ex]
\midrule
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
Item1&Item1\\
\bottomrule
\end{longtable}%
\hspace*{-12mm}%
\vspace{50mm}
\label{table:ETD Raman}
%\end{table}
\end{document}
谢谢大家的帮助!