使用\centering
或table
环境似乎不会更改表格内的文本。使用 tikz 或 的图形应该没有问题microtype
。
怎样才能使它们居中而没有左边距(用尽所有页面水平空间)?
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsmath,amssymb}
\usepackage{listingsutf8}
\usepackage{blindtext}
\usepackage[inline]{enumitem}
\usepackage{tabularx}
\usepackage{microtype}
\usepackage{tikz}
\usetikzlibrary{calc}
\setlist[itemize]{topsep=0pt,after=\newline}
\hyphenpenalty=10000
\exhyphenpenalty=10000
\newcommand{\tableau}[1]{{\sffamily #1}}
\newcommand\tab[1][0.75cm]{\hspace*{#1}}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand*{\DrawArrow}[3][]{%
% #1 = draw options
% #2 = left point
% #3 = right point
\begin{tikzpicture}[overlay,remember picture]
\draw [thick, -stealth, #1] ($(#2)+(0.35em,-0.5ex)$) to ($(#3)+(0.25em,-0.5ex)$);
\end{tikzpicture}%
}%
\begin{document}
\blindtext
\begin{enumerate}[
leftmargin=0pt,
itemindent=15pt,
listparindent=0.7cm,
labelwidth=15pt,
itemsep=10pt,
parsep=7.5pt,
]
\item {\sffamily acgaccccaa}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{4}{c}}
\$ & a & c & g\\
\{10\} & \{0,3,8,9\} & \{\tikzmark{1}1,4,5,6,7\} & \{\tikzmark{2}2\}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{2}{1}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{5}{c}}
\$ & a & c & cg & g\\
\{10\} & \{\tikzmark{0}0,3,8,9\} & \{4,5,6,7\} & \{\tikzmark{1}1\} & \underline{\{2\}}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{1}{0}
\vspace{0.5cm}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{6}{c}}
\$ & a & acg & c & cg & g\\
\{10\} & \{\tikzmark{3}3,8,9\} & \{0\} & \{\tikzmark{4}4,\tikzmark{5}5,\tikzmark{6}6,\tikzmark{7}7\} & \underline{\{1\}} & \underline{\{2\}}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{4}{3}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{5}{3}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{6}{3}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{7}{3}
\vspace{0.5cm}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{7}{c}}
\$ & a & acccc & acg & c & cg & g\\
\underline{\{10\}} & \underline{\{8,9\}} & \underline{\{3\}} & \underline{\{0\}} & \underline{\{4,5,6,7\}} & \underline{\{1\}} & \underline{\{2\}}
\end{tabular*}
}
\item {\sffamily aeeeaaeabceeedee}
\textls[120]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{6}{c}}
\$ & a & b & c & d & e\\
\{16\} & \{\tikzmark{0}0,4,\tikzmark{5}5,7\} & \{8\} & \{\tikzmark{9}9\} & \{\tikzmark{13}13\} & \{\tikzmark{1}1,\tikzmark{2}2,\tikzmark{3}3,\tikzmark{6}6,\tikzmark{10}10,\tikzmark{11}11,\tikzmark{12}12,\tikzmark{14}14,\tikzmark{15}15\}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{1}{0}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{2}{0}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{3}{0}
\DrawArrow[blue,out=-90, in=-90, bend right = -18]{6}{5}
\DrawArrow[blue,out=-90, in=-90, bend right = -39]{10}{9}
\DrawArrow[blue,out=-90, in=-90, bend right = -39]{11}{9}
\DrawArrow[blue,out=-90, in=-90, bend right = -39]{12}{9}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{14}{13}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{15}{13}
\vspace{1.5cm}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{8}{c}}
\$ & a & ae & aeee & b & ceee & dee & e\\
\{16\} & \{4,7\} & \{6\} & \{0\} & \{8\} & \{\tikzmark{9}9\} & \{\tikzmark{13}13\} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{13}{9}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{8}{c}}
\$ & a & ae & aeee & b & ceeedee & dee & e\\
\{16\} & \{4,7\} & \{6\} & \{0\} & \{\tikzmark{8}8\} & \{\tikzmark{9}9\} & \underline{\{13\}} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{9}{8}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{8}{c}}
\$ & a & ae & aeee & bceeedee & ceeedee & dee & e\\
\{16\} & \{4,\tikzmark{7}7\} & \{6\} & \{0\} & \{\tikzmark{8}8\} & \underline{\{9\}} & \underline{\{13\}} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{8}{7}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{8}{c}}
\$ & abceeedee & ae & aeee & bceeedee & ceeedee & dee & e\\
\{16\} & \{\tikzmark{4}4,7\} & \{\tikzmark{6}6\} & \underline{\{0\}} & \underline{\{8\}} & \underline{\{9\}} & \underline{\{13\}} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular*}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{6}{4}
\textls[80]{
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{9}{c}}
\$ & abceeedee & abceeedeeae & ae & aeee & bceeedee & ceeedee & dee & e\\
\underline{\{16\}} & \underline{\{7\}} & \underline{\{4\}} & \underline{\{6\}} & \underline{\{0\}} & \underline{\{8\}} & \underline{\{9\}} & \underline{\{13\}} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular*}
}
\end{enumerate}
\end{document}
结果如下:我希望表格沿页面居中。
我希望看到的是每个表格都与页面中心对齐,没有左边距,所有表格都真正位于页面中心。
最后 2 到 3 个表格比 更宽\textwidth
,因此它们无法很好地对齐。
答案1
存在段落缩进和不必要的空格。添加\noindent
和注释行尾会有所帮助。此外,\linewidth
当前行宽是否由其他环境设置,例如enumerate
、quote
、...
\noindent
\textls[80]{%
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}*{4}{c}}
\$ & a & c & g\\
\{10\} & \{0,3,8,9\} & \{\tikzmark{1}1,4,5,6,7\} & \{\tikzmark{2}2\}
\end{tabular*}%
}
其余的超满\hbox
警告是表格宽度过大的情况。切换到横向或重新设计布局。
答案2
我找到了一个解决方案:而不是tabular*
,tabular
就足够了,并且有了makebox
和center
环境,它就可以实现我想要的居中效果。
\begin{center}
\makebox[\textwidth][c]{
\textls[80]{
\begin{tabular}{*{8}{c}}
\$ & abceeedee & ae & aeee & bceeedee & ceeedee & dee & e\\
\{16\} & \{\tikzmark{4}4,7\} & \{\tikzmark{6}6\} & \underline{\{0\}} & \underline{\{8\}} & \underline{\{9\}} & \underline{\{13\}} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular}
}
}
\DrawArrow[blue,out=-90, in=-90, bend right = -30]{6}{4}
\makebox[\textwidth][c]{
\textls[80]{%
\begin{tabular}{*{9}{c}}
\$ & abceeedee & abceeedeeae & ae & aeee & bceeedee & ceeedee & dee & e\\
\underline{\{16\}} & \underline{\{7\}} & \underline{\{4\}} & \underline{\{6\}} & \underline{\{0\}} & \underline{\{8\}} & \underline{\{9\}} & \underline{\{13\}} & \underline{\{1,2,3,6,10,11,12,14,15\}}
\end{tabular}%
}
}
\end{center}