使用 LYX 按不同级别(长度)缩进表格的行

使用 LYX 按不同级别(长度)缩进表格的行

我必须创建一个包含 200 多行的长表,并且行以不同的长度(级别)缩进,Lyx 中有一个用于缩进的按钮,但它不起作用。示例在这里

`%% LyX 2.0.4 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{longtable}
\usepackage{float}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[table]{xcolor}

% define lightgray
\definecolor{lightgray}{gray}{0.9}

% alternate rowcolors for all long-tables
\let\oldlongtable\longtable
\let\endoldlongtable\endlongtable
\renewenvironment{longtable}{\rowcolors{2}{white}{lightgray}\oldlongtable} {
\endoldlongtable}

\makeatother

\usepackage{babel}
\begin{document}
\begin{longtable}{lc}
\hline 
\textbf{SECURITY} & \textbf{CODE}\tabularnewline
\hline 
\endhead
\textbf{I. Gold Bullion,Ornaments,Precious Metals} & \textbf{0000}\tabularnewline
\textbf{II. Sec.,Shares And Other Financial Instruments} & \tabularnewline
 (A)1. To Stock Brokers and Dealers & \tabularnewline
     A) Govt. \& Others Trustee Securities-Quoted & 1001\tabularnewline
     B) Shares and Debentures-Quoted & 1002\tabularnewline
     C) Participation Term Certificates-Quoted & 1003\tabularnewline
     D) Others-Quoted & 1009\tabularnewline
 (A)2. To Others & \tabularnewline
     A) Govt. \& Other Trustee Securities-Quoted & 1011\tabularnewline
     B) Shares and Debentures-Quoted & 1012\tabularnewline
     C) Participation Term Certificates-Quoted & 1013\tabularnewline
     D) Others-Quoted & 1019\tabularnewline

\hline 
\end{longtable}
\end{document}

' 期望的输出应该是这样的 在此处输入图片描述

答案1

通常的做法是使用两列,并使用\multicolumn{2}{l}{<text>}跨越<text>两列。缩进的文本从第二列开始,因此需要&在开头使用:

在此处输入图片描述

代码:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{longtable}
\usepackage{float}

\makeatletter

\providecommand{\tabularnewline}{\\}
\usepackage[table]{xcolor}

% define lightgray
\definecolor{lightgray}{gray}{0.9}

% alternate rowcolors for all long-tables
\let\oldlongtable\longtable
\let\endoldlongtable\endlongtable
\renewenvironment{longtable}{\rowcolors{2}{white}{lightgray}\oldlongtable} {
\endoldlongtable}

\makeatother

\usepackage{babel}
\begin{document}
\begin{longtable}{llc}
\hline 
 \multicolumn{2}{l}{\textbf{SECURITY}} & \textbf{CODE}\tabularnewline
\hline 
\endhead
 \multicolumn{2}{l}{\textbf{I. Gold Bullion,Ornaments,Precious Metals}} & \textbf{0000}\tabularnewline
 \multicolumn{2}{l}{\textbf{II. Sec.,Shares And Other Financial Instruments}} & \tabularnewline
 \multicolumn{2}{l}{(A)1. To Stock Brokers and Dealers} & \tabularnewline
     & A) Govt. \& Others Trustee Securities-Quoted & 1001\tabularnewline
     & B) Shares and Debentures-Quoted & 1002\tabularnewline
     & C) Participation Term Certificates-Quoted & 1003\tabularnewline
     & D) Others-Quoted & 1009\tabularnewline
 \multicolumn{2}{l}{(A)2. To Others} & \tabularnewline
     & A) Govt. \& Other Trustee Securities-Quoted & 1011\tabularnewline
     & B) Shares and Debentures-Quoted & 1012\tabularnewline
     & C) Participation Term Certificates-Quoted & 1013\tabularnewline
     & D) Others-Quoted & 1019\tabularnewline

\hline 
\end{longtable}
\end{document}

相关内容