tabularx:为什么单元格中的列表格式存在差异

tabularx:为什么单元格中的列表格式存在差异

请考虑姆韦吼叫:

\documentclass[11pt,a4paper]{report}
\usepackage[margin=2.5cm]{geometry}
\usepackage[english]{babel}

\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X}

\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
    \setlist[itemize]{nosep,
                      wide,%leftmargin = *,
                      before     = \vspace{-\baselineskip},
                      after      = \vspace{-\baselineskip}
                        }
                           }% end of AtBeginEnvironment

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[htbp]
    \small
\begin{tabularx}{\linewidth}{@{} p{15mm} L L L
                             @{}}
\toprule
    &
    Integration of heterogeneous data &
    Algorithms to identify urban features &
    Improve accuracy for spectral classification algorithms \\
\midrule
    Objective &
    \begin{itemize}
    \item   Improve the spatial and spectral resolution
    \item   Enhance the ability of features detection and display
    \item   Promote the geometric precision
    \end{itemize}
    &
    \begin{itemize}
    \item   Accelerate future processing and improve classification accuracy
    \item   Automated processes for detecting, extracting, simulating, classifying and modelling urban features
    \end{itemize}
    &
    \begin{itemize}
    \item   Capability of separating urban land-cover and land-use classes in an adequate manner
    \end{itemize}       \\
\bottomrule
\end{tabularx}
    \end{table}

    \begin{table}[htbp]
    \small
\begin{tabularx}{\linewidth}{@{} >{\hsize=0.4\hsize}L
                            *{3}{>{\hsize=1.2\hsize}L}
                            @{}}
\toprule
    &
    Integration of heterogeneous data &
    Algorithms to identify urban features &
    Improve accuracy for spectral classification algorithms \\
\midrule
    Objective &
    \begin{itemize}
    \item   Improve the spatial and spectral resolution
    \item   Enhance the ability of features detection and display
    \item   Promote the geometric precision
    \end{itemize}
    &
    \begin{itemize}
    \item   Accelerate future processing and improve classification accuracy
    \item   Automated processes for detecting, extracting, simulating, classifying and modelling urban features
    \end{itemize}
    &
    \begin{itemize}
    \item   Capability of separating urban land-cover and land-use classes in an adequate manner
    \end{itemize}       \\
\bottomrule
\end{tabularx}
    \end{table}
\end{document}

在此处输入图片描述

我们可以看到,在两种情况下,列的宽度是相同的。为什么列表的格式不同?

答案1

在此处输入图片描述

直接设置\hsize当然不是乳胶支持的事情,这意味着任何嵌套列表结构都不知道它应该有多宽,设置\linewidth为新的\hsize可以让事情回到正轨。

文档tabularx也许应该记录这一点,尽管它确实记录了所有X列必须具有相同的宽度,除非你违反规则.....

\documentclass[11pt,a4paper]{report}
\usepackage[margin=2.5cm]{geometry}
\usepackage[english]{babel}

\usepackage{ragged2e}
\usepackage{booktabs, tabularx}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X}

\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
    \setlist[itemize]{nosep,
                      wide,%leftmargin = *,
                      before     = \vspace{-\baselineskip},
                      after      = \vspace{-\baselineskip}
                        }
                           }% end of AtBeginEnvironment

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[htbp]
    \small
\begin{tabularx}{\linewidth}{@{} p{15mm} L L L
                             @{}}
\toprule
    &
    Integration of heterogeneous data &
    Algorithms to identify urban features &
    Improve accuracy for spectral classification algorithms \\
\midrule
    Objective &
    \begin{itemize}
    \item   Improve the spatial and spectral resolution
    \item   Enhance the ability of features detection and display
    \item   Promote the geometric precision
    \end{itemize}
    &
    \begin{itemize}
    \item   Accelerate future processing and improve classification accuracy
    \item   Automated processes for detecting, extracting, simulating, classifying and modelling urban features
    \end{itemize}
    &
    \begin{itemize}
    \item   Capability of separating urban land-cover and land-use classes in an adequate manner
    \end{itemize}       \\
\bottomrule
\end{tabularx}
    \end{table}

    \begin{table}[htbp]
    \small
\begin{tabularx}{\linewidth}{@{} >{\hsize=0.4\hsize\linewidth=\hsize}L
                            *{3}{>{\hsize=1.2\hsize\linewidth=\hsize}L}
                            @{}}
\toprule
    &
    Integration of heterogeneous data &
    Algorithms to identify urban features &
    Improve accuracy for spectral classification algorithms \\
\midrule
    Objective &
    \begin{itemize}
    \item   Improve the spatial and spectral resolution
    \item   Enhance the ability of features detection and display
    \item   Promote the geometric precision
    \end{itemize}
    &
    \begin{itemize}
    \item   Accelerate future processing and improve classification accuracy
    \item   Automated processes for detecting, extracting, simulating, classifying and modelling urban features
    \end{itemize}
    &
    \begin{itemize}
    \item   Capability of separating urban land-cover and land-use classes in an adequate manner
    \end{itemize}       \\
\bottomrule
\end{tabularx}
    \end{table}
\end{document}

为了获得完全相同的换行符,您可以使用

\begin{tabularx}{\linewidth}{@{} >{\hsize=.406\hsize\linewidth=\hsize}L
                            *{3}{>{\hsize=1.198\hsize\linewidth=\hsize}L}
                            @{}}

相关内容