You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX Tabularx表格内容对齐(含itemize列表)、表头居中及边框衔接问题咨询

解决tabularx表格的排版问题

我来帮你逐个搞定这三个排版痛点,直接上修改后的完整代码和关键说明:

1. 修复边框断开问题

你同时用了booktabs的\toprule/\midrule/\bottomrule和表格竖线|——这俩天生不兼容!booktabs的规则线是为无竖线的专业学术表格设计的,和竖线搭配就会出现边角断开的情况。有两个解决方向:

  • 方案A:删掉所有竖线,纯用booktabs的横线(推荐,符合学术表格规范)
  • 方案B:放弃booktabs的特殊横线,改用普通\hline/\cline,保证竖线和横线完美衔接

下面的代码用方案B匹配你原来的带竖线需求。

2. 调整itemize列表对齐(左对齐/居中)

单元格里的默认itemize有多余左缩进,要让列表和单元格边界对齐,或者居中,得用enumitem自定义列表样式,同时配合\compress命令减少单元格内边距。

3. 表头居中对齐

tabularx的X列默认左对齐,要让表头居中,要么给每个表头单元格加\centering,要么直接把X列设置为全局居中格式。

修改后的完整LaTeX代码

\documentclass[ paper=a4, portrait, fontsize=12pt, version=last, twoside, english, titlepage, toc=listof, toc=bibliography, usenames,dvipsnames,svgnames,table ]{scrbook}
\usepackage[a4paper,left=3cm,right=4cm,top=2cm,bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[babel]{csquotes}
\usepackage[super]{nth}
\usepackage{tabularx}
\usepackage{setspace}
\onehalfspacing
\usepackage{scrhack}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{booktabs}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{hyperref}
\usepackage{caption}
\captionsetup{width=\textwidth} % 修复原标题超出页面的问题
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{ifdraft}
\ifdraft{\let\ifxdraft\iftrue}{\let\ifxdraft\iffalse}
\clubpenalty = 10000
\widowpenalty = 10000
\displaywidowpenalty = 10000
\usepackage{listings}
\lstdefinestyle{code}{ backgroundcolor=\color{white}, basicstyle=\footnotesize\ttfamily,, breakatwhitespace=false, breaklines=true, captionpos=b, commentstyle=\color{blue}, extendedchars=true, frame=single, identifierstyle=, keepspaces=true, keywordstyle=\color{Sepia}, language=C, numbers=left, numbersep=5pt, numberstyle=\tiny\color{gray}, rulecolor=\color{black}, showspaces=false, showstringspaces=false, showtabs=false, stepnumber=1, stringstyle=\color{orange}, tabsize=1, title=\lstname }
\lstdefinestyle{text}{ backgroundcolor=\color{white}, basicstyle=\footnotesize\ttfamily,, breakatwhitespace=false, breaklines=true, captionpos=b, extendedchars=true, frame=single, keepspaces=true, numbers=left, numbersep=5pt, numberstyle=\tiny\color{gray}, rulecolor=\color{black}, showspaces=false, showstringspaces=false, showtabs=false, stepnumber=1, tabsize=1, title=\lstname }
\usepackage{enumitem}
\usepackage{tabularx, makecell}
\usepackage{multicol}
\usepackage{ltablex}
\keepXColumns
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\definecolor{maroon}{cmyk}{0,0.87,0.68,0.32}
\newcommand{\gray}{\rowcolor[gray]{.90}}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{siunitx}
\usepackage{marginnote}
\title{Business Intelligence to Support an Indicator-Based Waste Incineration Process}
\author{Mohammadjavad Ranji}
\date{\today}
\makeatletter
\let\ThesisTitle\@title
\let\ThesisDate\@date
\makeatother

% 自定义表格内的itemize样式,解决对齐问题
\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{
    leftmargin=*, % 去掉左缩进,列表左对齐单元格边界
    label=\textbullet,
    nosep, % 缩小列表项间距
    before=\compress
}
% 如果要让列表居中,把上面的before改成:before=\compress\centering

\begin{document}
\begin{tabularx}{\textwidth}{|*{3}{>{\compress}X|}}
\caption{caption} 
\label{tab:table1label} \\
\hline % 替换booktabs命令,修复边框断开
\centering head1 & \centering head2 & \centering head3 \\ % 表头居中
\hline
\endfirsthead
%---------------------------------------------------------------%
\caption{caption (continued)} \\
\hline
\centering head1 & \centering head2 & \centering head3 \\
\hline
\endhead
%---------------------------------------------------------------%
\multicolumn{3}{r}{\footnotesize\textit{continued on the next page}}
\endfoot
\hline
\endlastfoot
\hline
A & B & C \\
\hline
col1\_content & \begin{tabitem}
\item col2 list item1
\item col2 list item2
\end{tabitem} & \begin{tabitem}
\item col3 list item1
\item col3 list item2
\end{tabitem} \\
\hline
\end{tabularx}
\end{document}

关键修改点总结

  • 边框修复:用\hline替换所有booktabs的横线命令,竖线和横线就能完美衔接;如果想保留booktabs的美观效果,删掉表格列格式里的|即可。
  • 列表对齐:自定义tabitem列表样式,leftmargin=*实现左对齐,要居中就加\centering,nosep让列表更紧凑。
  • 表头居中:给每个表头单元格加\centering,或者直接把列格式改成>{\centering\compress}X实现全列居中。
  • 额外修复:把\captionsetup{width=2\textwidth}改成width=\textwidth,避免标题超出页面边界。

内容的提问来源于stack exchange,提问作者mjr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 16:22:33