我在 Lyx 中使用多行表格进行垂直对齐时遇到了麻烦。我有“树”格式的数据,需要在表格中显示。我希望类别 1、子类别 1.1 和值 1 都垂直对齐,类别 2、子类别 2.1 等也一样。有什么建议吗?只要我使用多行,Lyx 中的常规“对齐顶部”选项就会被禁用。
这是我的 lyx 文件创建的 latex 源:
% Preview source code
%% LyX 2.0.0 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{multirow}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\makeatother
\usepackage{babel}
\begin{document}
\begin{tabular*}{1\columnwidth}{@{\extracolsep{\fill}}>{\raggedright}m{0.33\columnwidth}>{\raggedright}m{0.33\columnwidth}>{\centering}p{0.33\columnwidth}}
Column 1 & Column 2 & Column 3\tabularnewline
\multirow{4}{0.33\columnwidth}{Category 1 With very long text that wraps} & \multirow{2}{0.33\columnwidth}{Subcategory 1.1} & Value 1\tabularnewline
& & Value 2\tabularnewline
& \multirow{2}{0.33\columnwidth}{Subcategory 1.2} & Value 3\tabularnewline
& & Value 4\tabularnewline
\multirow{2}{0.33\columnwidth}{Category 2} & Subcategory 2.1 & Value 5\tabularnewline
& Subcategory 2.2 & Value 6\tabularnewline
\end{tabular*}
\end{document}
答案1
我不确定您想要的对齐方式;也许是这样的?
\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{multirow}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\makeatother
\usepackage{babel}
\begin{document}
\begin{tabular*}{1\columnwidth}{@{\extracolsep{\fill}}>{\raggedright}m{0.33\columnwidth}>{\raggedright}m{0.33\columnwidth}>{\centering}p{0.33\columnwidth}}
Column 1 & Column 2 & Column 3\tabularnewline
\multirow{2}{0.33\columnwidth}{Category 1 With very long text that wraps} & Subcategory 1.1 & Value 1\tabularnewline
& & Value 2\tabularnewline
& Subcategory 1.2 & Value 3\tabularnewline
& & Value 4\tabularnewline
Category 2 & Subcategory 2.1 & Value 5\tabularnewline
& Subcategory 2.2 & Value 6\tabularnewline
\end{tabular*}
\end{document}