我有一张 2x5 大小的表格。我使用了表格环境来定义它。我只希望标题(前两个单元格)居中,但表格的其余部分应左对齐。
\documentclass[a4paper, %Papiergröße
12pt, %Schriftgröße
headsepline, %Linie zwischen Text und Kopfzeile
twoside, %zweiseitiges Layout
BCOR18mm, %Binderand von 18mm
DIV14, %14x14 Streifen pro Seite
dvipsnames,
cmyk]{scrreprt}
\usepackage{tabstackengine,amssymb}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{tabularx}
\usepackage{booktabs}
\usetikzlibrary{tikzmark,calc}
\stackMath
\newcommand{\myq}{\,\,\,}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newlength\replength
\newcommand\ruleht{0pt}% ELEVATION OF RULE
\newcommand\repfrac{.6}% SOLID FRACTION OF DASH LINE [0->1] (USE 1 FOR SOLID)
\replength=.2em\relax% PERIOD OF DASHED RULE
\newcommand\rulewidth{.4pt}% THICKNESS OF RULE
\newcommand\drulefill{\leavevmode\dashfill\hfil%
\kern\dimexpr\repfrac\replength-\replength\relax}
\newcommand\dashfill[1][\repfrac]{\cleaders\hbox to \replength{%
\smash{\rule[\ruleht]{\repfrac\replength}{\rulewidth}}}\hfill}
\newcommand\udash[2][\hrulefill]{%
\setbox0=\hbox{\stackon{\kern.7em}{\,#2\,}}%
\stackunder{#2}{\makebox[\wd0]{#1}}}
\newcommand\uddash[1]{\udash[\drulefill]{#1}}
\newcommand\mygap{\hspace{.7em}}
\begin{document}
\begin{center}
\setlength\arrayrulewidth{1pt}
\begin{tabular}{c|c}
$\rho_r : (\forall X_r)$ $p_r[ \tabbedShortunderstack{\udash{L_r}\\R_r} ]$ & $\rho_\omega : (\forall X_\omega)$ $p_\omega[ \tabbedShortunderstack{\udash{L_\omega}\\R_\omega} ]$ \\
\hline
$X_r=\{x,i,k,\sigma\}$ & $X_\omega=\{x,i,i',k,\sigma\}$ \\
$W_r=\{\Box\}$ & $W_\omega=\{\Box_1,\Box_2\}$ \\
$p_r=\langle\Box\curvearrowright k\rangle_k \langle\sigma\,x\mapsto i\rangle_{state}$ & $p_\omega=\langle\Box_1\curvearrowright k\rangle_k \langle\sigma\,x\mapsto \Box_1\rangle_{state}$ \\
$L_r(\Box)=x$ & $L(\Box_1)=x=i'$; und $L(\Box_2)=i$ \\
$R_r(\Box)=i$ & $R(\Box_1)=\cdot$ und $R(\Box_2)=i'$ \\
\end{tabular}
\end{center}
\end{document}
垂直线后的其余部分应左对齐。我该如何实现?
谢谢!
答案1
您可以(滥用)使用\multicolumn
。也就是说,您可以创建一个 1 列的“多”列,在其中选择c
对齐方式,而整体对齐方式是l
。我还删除了这里未使用的包和命令。
\documentclass[a4paper, %Papiergröße
12pt, %Schriftgröße
headsepline, %Linie zwischen Text und Kopfzeile
twoside, %zweiseitiges Layout
BCOR18mm, %Binderand von 18mm
DIV14, %14x14 Streifen pro Seite
dvipsnames,
cmyk]{scrreprt}
\usepackage{tabstackengine}
\usepackage{amsmath,amssymb}
\stackMath
\newcommand\udash[2][\hrulefill]{%
\setbox0=\hbox{\stackon{\kern.7em}{\,#2\,}}%
\stackunder{#2}{\makebox[\wd0]{#1}}}
\begin{document}
\begin{center}
\setlength\arrayrulewidth{1pt}
\begin{tabular}{l|l}
\multicolumn{1}{c|}{$\rho_r : (\forall X_r)$ $p_r[
\tabbedShortunderstack{\udash{L_r}\\R_r} ]$} &
\multicolumn{1}{c}{$\rho_\omega : (\forall X_\omega)$ $p_\omega[
\tabbedShortunderstack{\udash{L_\omega}\\R_\omega} ]$} \\
\hline
$X_r=\{x,i,k,\sigma\}$ & $X_\omega=\{x,i,i',k,\sigma\}$ \\
$W_r=\{\Box\}$ & $W_\omega=\{\Box_1,\Box_2\}$ \\
$p_r=\langle\Box\curvearrowright k\rangle_k \langle\sigma\,x\mapsto i\rangle_{state}$ & $p_\omega=\langle\Box_1\curvearrowright k\rangle_k \langle\sigma\,x\mapsto \Box_1\rangle_{state}$ \\
$L_r(\Box)=x$ & $L(\Box_1)=x=i'$; und $L(\Box_2)=i$ \\
$R_r(\Box)=i$ & $R(\Box_1)=\cdot$ und $R(\Box_2)=i'$ \\
\end{tabular}
\end{center}
\end{document}