长表内的文本项未垂直对齐

长表内的文本项未垂直对齐

我的问题可能与此类似表格单元格内的项目列表未对齐,但该解决方案不适合我的情况。

使用以下代码:

\documentclass[a4paper, 11pt]{article} 
\usepackage[margin=2cm]{geometry} % changes the margin
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{longtable}
\usepackage{blindtext}


%% Create a very compact enumerated list environment
\newlist{myenum}{enumerate}{1}
\setlist[myenum]{label=\arabic*., nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip}} % reducing vertical   space
%---------------------Need to Simplify This-----------------------------%
\newlist{myenum2}{enumerate}{1}
\setlist[myenum2]{label=\alph*), nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip}} % reducing vertical space
\newlist{myenum3}{enumerate}{1}
\setlist[myenum3]{label=\arabic*), nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip}} % reducing vertical space
\newlist{myenum4}{enumerate}{1}
\setlist[myenum4]{label=\arabic*., nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip},
             start=2} % reducing vertical space
\newlist{myenum5}{enumerate}{1}
\setlist[myenum5]{label=\arabic*., nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip},
             start=3} % reducing vertical space
\newlist{myenum6}{enumerate}{1}
\setlist[myenum6]{label=\arabic*., nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip},
             start=4} % reducing vertical space
\newlist{myenum7}{enumerate}{1}
\setlist[myenum7]{label=\arabic*., nosep, wide, 
             leftmargin=*, % hanging indentation
             before=\vspace{-0.57\baselineskip},
             after =\vspace{-0.8\baselineskip},
             start=5} % reducing vertical space               

\renewcommand\thesection{\Alph{section}.}
\renewcommand\thesubsection{\arabic{subsection}.}
%% Re-format the font size of "the section"
% {11} is the desired font size
% {15} is the vertical spacing, perhaps refers to 1.5 lines?
% \selectfont is for un-bold the sub-section
\titleformat{\section}
{\normalfont\fontsize{11}{.5em}\bfseries}{\thesection}{.5em}
    {}
\titleformat{\subsection}
{\normalfont\fontsize{11}{.5em}\selectfont}{\thesubsection}{.5em}
    {}
\titlespacing % starred version: first paragraph is not indented
{\subsection} % <command>
{0em} % <left>
{.4em} % <before-sep>
{.3em} % <after-sep>

\setlength\parindent{1cm} 

% Avoid hypenation (breaking sentences in paragraph)
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000

\begin{document}
%------------------------------Section D---------------------------------------------%
\section{Some Text Here}
\begin{longtable}{@{}p{0.3\textwidth}cp{0.65\textwidth}}
%% Subsection 1
\begin{myenum} \item Some Text Here \end{myenum} & : & \blindtext \\
%% Subsection 2
\begin{myenum4} \item Some Text Here \end{myenum4} & : & \blindtext \\
%% Subsection 3
\begin{myenum5} \item Some Text Here \end{myenum5} & : & \begin{myenum3}
\item Some Text Here;
\item Some Text Here;
\item Some Text Here;
\item Some Text Here;
\item Some Text Here;
\item Some Text Here.
\end{myenum3}\\
%% Subsection 4
\begin{myenum6} \item Some Text Here \end{myenum6} & : &   \begin{myenum2} 
\item \blindtext; 
\item \blindtext;  
\end{myenum2}\\
%% Subsection 5
\begin{myenum7} \item{Some Text Here} \end{myenum7} & : & \blindtext.\\
\end{longtable}
\end{document}

结果是这样的[输出1][ ][1]]1[ 输出2]2

我的问题是:

  1. 我知道使用 \newlist 和 \setlist,我可以在第一列创建一个自定义的枚举列表,但是有没有更优雅的方法呢?answered
  2. 我如何制作一个跨越多页的表格,其中第一列是编号列表,第二列是文本,:第三列是符号,第四列是编号列表,并使它们垂直对齐?
  3. 我怎样才能减少 \section 和其后的文本之间不必要的垂直空间?answered

任何帮助将不胜感激。

答案1

如果使用自定义环境的唯一原因enumerate是在第一列自动插入计数器,我建议您按如下方式操作。请注意,longtabletabular环境都具有一个列(类型N),该列被编程为增加计数器,然后立即将其打印出来。

\label请注意,可以通过通常的机制轻松地交叉引用特定行\ref

在此处输入图片描述

\documentclass[a4paper, 11pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{array,longtable,etoolbox,lipsum}
\setlength\extrarowheight{2pt} % for a more open "look" of tabular material
\newcolumntype{P}[1]{p{#1\textwidth}}

\newcounter{rownum}
\newcolumntype{N}{>{\refstepcounter{rownum}\therownum}l}
% Automate resetting of counter to 0 at the start of a tabular-like env.:
\AtBeginEnvironment{tabular}{\setcounter{rownum}{0}}
\AtBeginEnvironment{tabular*}{\setcounter{rownum}{0}}
\AtBeginEnvironment{tabularx}{\setcounter{rownum}{0}}
\AtBeginEnvironment{longtable}{\setcounter{rownum}{0}}

\begin{document}

\begingroup  % localize the following settings
\setlength\tabcolsep{0pt} % <--- important
\setlength\LTleft{0pt} \setlength\LTright{0pt}

\begin{longtable}{@{\extracolsep{\fill}} N P{0.32} P{0.63}} 
   % rel. column widths of the "P" columns should sum to no more than 0.95.
\hline
\endfirsthead
\hline
\endlastfoot

& Some text here      & \lipsum*[1] \\[1ex]
& Some more text here & \lipsum*[2] \\

\end{longtable}
\endgroup


\begin{center}
\begin{tabular}{@{} N lll @{}}
\hline
& a & b & c \\
& d & e & f \\
\label{row:last}& g & h & i \\
\hline
\end{tabular}
\end{center}

%% Create a cross-reference to the final row:
\noindent
A cross-reference to row \ref{row:last}.
\end{document}

相关内容