表格中的项目符号 - 减少行间距

表格中的项目符号 - 减少行间距

我想将包含一些项目符号的 Excel 表格转换为 LaTeX 表格;为此,我使用了 Excel2Latex 插件。当我将(由插件生成的)代码粘贴到 Overleaf 时,我注意到这个项目符号符号 · 发生了一些变化(参见第一张图片)。我将此符号替换为“\tabitem”,成功了。我的问题是我不喜欢项目符号之间的这些大空格(参见第二张图片)。我认为它们是由于其他表格列的项目有多行而创建的。我该如何消除它们?

我已附上代码。

\documentclass[11pt, twoside]{book}


\usepackage[english]{babel}
%% Sets page size and margins
\usepackage[a4paper,top=3cm,bottom=2cm,left=2cm,right=2cm,marginparwidth=1.75cm]{geometry}
\usepackage[final]{pdfpages}
\usepackage{booktabs}
\usepackage{enumitem}
\newcommand{\tabitem}{\textbullet~~}

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Vulnerability indicators to soil moisture and groundwater urban drought}
  \resizebox{0.95\columnwidth}{!}{%
    \begin{tabular}{p{21.945em}r}
    \toprule
    Soil Moisture & \multicolumn{1}{p{25.78em}}{Groundwater} \\
    \midrule
    Exposure  & \multicolumn{1}{p{25.78em}}{Exposure } \\
    \midrule
    Physical characteristics & \multicolumn{1}{p{25.78em}}{Physical characteristics} \\
    \tabitem Potential evaporation based on the geographical location (indirect) & \multicolumn{1}{p{25.78em}}{\tabitem Urban Groundwater Drought deficit based on past events} \\
    \tabitem Soil moisture drought deficit based on past events & \multicolumn{1}{p{25.78em}}{\tabitem Average duration of Urban Groundwater Drought deficit based on past events} \\
    \tabitem Duration of Urban Soil moisture drought deficit based on past events & \multicolumn{1}{p{25.78em}}{\tabitem Frequency of Standardized Groundwater Index (SGI)} \\
    \tabitem Frequency of Urban Soil Moisture Drought Events &  \\
    \midrule
    Sensitivity & \multicolumn{1}{p{25.78em}}{Sensitivity} \\
    \midrule
    Physical characteristics & \multicolumn{1}{p{25.78em}}{Physical characteristics} \\
    \tabitem Percentage of soils with high permeability & \multicolumn{1}{p{25.78em}}{\tabitem Percentage of soils with high permeability} \\
    \tabitem Percentage of urban agricultural area to total city area & \multicolumn{1}{p{25.78em}}{\tabitem Building density} \\
    \tabitem Percentage of urban gardens, parks, forests to total city’s area & \multicolumn{1}{p{25.78em}}{\tabitem Percentage of building on wooden piles} \\
    \tabitem Percentage of parks which are irrigated & \multicolumn{1}{p{25.78em}}{\tabitem Percentage of cultural heritage buildings on wooden piles} \\
    \tabitem Percentage of parks whose plants\textbackslash{}trees require little water & \multicolumn{1}{p{25.78em}}{\tabitem Locations of critical infrastructure (e.g. hospital, electricity station)} \\
    \tabitem Existence of risk-reduced services & \multicolumn{1}{p{25.78em}}{\tabitem Location of enterprises} \\
    Political characteristics  & \multicolumn{1}{p{25.78em}}{\tabitem Groundwater extraction permits} \\
    \tabitem Existence of regulations regarding where parks, urban gardens, urban forests, and urban agricultural areas can be created and what kind of vegetation, crops, and tress can be planted & \multicolumn{1}{p{25.78em}}{Social characteristics} \\
    \multicolumn{1}{r}{} & \multicolumn{1}{p{25.78em}}{\tabitem Population density} \\
    \multicolumn{1}{r}{} & \multicolumn{1}{p{25.78em}}{\tabitem Percentage of minority population whose house is on wooden piles} \\
    \multicolumn{1}{r}{} & \multicolumn{1}{p{25.78em}}{\tabitem Financial status of residents whose house is on wooden piles (this could be in adaptive capacity as well)} \\
    \multicolumn{1}{r}{} & \multicolumn{1}{p{25.78em}}{Political characteristics} \\
    \multicolumn{1}{r}{} & \multicolumn{1}{p{25.78em}}{\tabitem Existence of regulations regarding the way buildings ought to be erected  and type of materials ought to be used eradicating the use of wooden poles} \\
    \midrule
    Adaptive Capacity & \multicolumn{1}{p{25.78em}}{Adaptive Capacity} \\
    \midrule
    Physical & \multicolumn{1}{p{25.78em}}{Physical} \\
    \tabitem Water availability for irrigation & \multicolumn{1}{p{25.78em}}{\tabitem Infiltration mechanisms to recharge the groundwater table if needed} \\
    \tabitem Water harvesting for watering urban parks & \multicolumn{1}{p{25.78em}}{Socio-Economic} \\
    Socio-economic & \multicolumn{1}{p{25.78em}}{\tabitem Educational level of residents (proxy for economic status) whose house is on wooden piles} \\
    \tabitem Unemployment rate (proxy for economic status) & \multicolumn{1}{p{25.78em}}{\tabitem Gross domestic product if the analysis takes place for cities and not for neighborhoods} \\
    Political & \multicolumn{1}{p{25.78em}}{\tabitem Public Budget Expenditure of the city} \\
    \tabitem Political status & \multicolumn{1}{p{25.78em}}{Political} \\
    \tabitem Existence of Contingency plans & \multicolumn{1}{p{25.78em}}{\tabitem Political status of the city} \\
    \tabitem Availability of water trucks for that water function & \multicolumn{1}{p{25.78em}}{\tabitem Existence of institutions with relevant competences} \\
    \tabitem Existence of institutions with relevant competences &  \\
    \end{tabular}%
    }
  \label{tab:addlabel}%
\end{table}%

\end{document}

在此处输入图片描述在此处输入图片描述

答案1

由于您的表格很可能太长而无法放在一页上,因此我建议使用longtable以允许表格中间分页。我还添加了自定义tabitemize环境以供在表格中使用。

从下面的截图中你可以看到,并不是所有的垂直空白都被删除了,因为我决定垂直对齐子标题(例如“政治特征”),以增加列表条目的可比性。 在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage{calc}
\usepackage{enumitem}
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{wide=0pt, nosep, leftmargin= * ,label=\textbullet,after=\vspace{-\baselineskip},before=\vspace{-0.6\baselineskip}}
\usepackage{longtable}
\usepackage{geometry}
\begin{document}

    \begin{longtable}{p{0.5\textwidth-2\tabcolsep}p{0.5\textwidth-2\tabcolsep}}
    \caption{Vulnerability indicators to soil moisture and groundwater urban drought}
    \label{tab:addlabel}\\
    \toprule
    Soil Moisture & Groundwater \\
    \midrule
    \endfirsthead
    \caption{Vulnerability indicators to soil moisture and groundwater urban drought - continued}\\
    \toprule
    Soil Moisture & Groundwater \\
    \midrule
    \endhead  
    Exposure  & Exposure  \\
    \midrule
    Physical characteristics 
    & Physical characteristics \\
    \begin{tabitemize}
    \item Potential evaporation based on the geographical location (indirect) 
    \item Soil moisture drought deficit based on past events
    \item Duration of Urban Soil moisture drought deficit based on past events
    \item Frequency of Urban Soil Moisture Drought Events
    \end{tabitemize}&
    \begin{tabitemize}
    \item Urban Groundwater Drought deficit based on past events 
    \item Average duration of Urban Groundwater Drought deficit based on past events 
    \item Frequency of Standardized Groundwater Index (SGI) 
    \end{tabitemize} \\
    \midrule
    Sensitivity & Sensitivity \\
    \midrule
    Physical characteristics & Physical characteristics \\*
    \begin{tabitemize}
    \item Percentage of soils with high permeability
    \item Percentage of urban agricultural area to total city area
    \item Percentage of urban gardens, parks, forests to total city’s area
    \item Percentage of parks which are irrigated
    \item Percentage of parks whose plants\textbackslash{}trees require little water
    \item Existence of risk-reduced services
    \end{tabitemize}& 
    \begin{tabitemize}
    \item Percentage of soils with high permeability
    \item Building density
    \item Percentage of building on wooden piles
    \item Percentage of cultural heritage buildings on wooden piles
    \item Locations of critical infrastructure (e.g. hospital, electricity station)
    \item Location of enterprises
    \item Groundwater extraction permits
    \end{tabitemize}\\ \addlinespace
      &  Social characteristics\\*
      &
    \begin{tabitemize}
    \item Population density
    \item Percentage of minority population whose house is on wooden piles
    \item Financial status of residents whose house is on wooden piles (this could be in adaptive capacity as well)
    \end{tabitemize}\\ \addlinespace
    Political characteristics & Political characteristics \\*
    \begin{tabitemize}
    \item Existence of regulations regarding where parks, urban gardens, urban forests, and urban agricultural areas can be created and what kind of vegetation, crops, and tress can be planted
    \end{tabitemize}&
    \begin{tabitemize}
    \item Existence of regulations regarding the way buildings ought to be erected  and type of materials ought to be used eradicating the use of wooden poles
    \end{tabitemize}\\
    \midrule \pagebreak
    Adaptive Capacity & Adaptive Capacity \\
    \midrule
    Physical & Physical \\*
    \begin{tabitemize}
    \item Water availability for irrigation
    \item Water harvesting for watering urban parks
    \end{tabitemize}&
    \begin{tabitemize}
    \item Infiltration mechanisms to recharge the groundwater table if needed
    \end{tabitemize}\\ \addlinespace
    Socio-economic & Socio-economic \\*
    \begin{tabitemize}
    \item Unemployment rate (proxy for economic status)
    \end{tabitemize} &
    \begin{tabitemize}
    \item Educational level of residents (proxy for economic status) whose house is on wooden piles
    \item Gross domestic product if the analysis takes place for cities and not for neighborhoods
    \end{tabitemize}\\ \addlinespace
    Political & Political \\*
    \begin{tabitemize}
    \item Political status
    \item Existence of Contingency plans
    \item Availability of water trucks for that water function
    \item Existence of institutions with relevant competences
    \end{tabitemize} &
    \begin{tabitemize}
    \item Public Budget Expenditure of the city
    \item Political status of the city
    \item Existence of institutions with relevant competences
    \end{tabitemize}\\
    \bottomrule
    \end{longtable}%


\end{document}

答案2

让我将我的评论延伸到答案中。在将 Excel 表转换为 LaTeX 时生成的清理代码之后,对表进行了重新组织。引入了列表Excel2Latex,而不是行。\tabitemitemize

表格设计对页面布局影响很大。由于不知道,我选择页面边框大小为 25mm(通过使用包geometry),表格标题为caption包。这样表格就可以放在一页上。

对于表环境使用tabularx,对于列表enumitem包使用:

在此处输入图片描述

(红线表示页面布局)

梅威瑟:

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{booktabs, tabularx}
\usepackage{enumitem}
\usepackage[skip=1ex,font=small, labelfont=bf]{caption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{table}
\setlist[itemize]{nosep=0pt,
                 leftmargin=*,
                 label=\textbullet,
                 after=\end{minipage},
                 before=\begin{minipage}[t]{\linewidth}
                 }
\caption{Vulnerability indicators to soil moisture and groundwater urban drought}
\label{tab:addlabel}%
    \begin{tabularx}{\linewidth}{@{}XX@{}}
    \toprule
Soil Moisture & Groundwater     \\
    \midrule
% table body
Exposure  & Exposure            \\
    \midrule
\emph{Physical characteristics}
    &   \emph{Physical characteristics}     \\
    \begin{itemize}
\item Potential evaporation based on the geographical location (indirect)
\item Soil moisture drought deficit based on past events
\item Duration of Urban Soil moisture drought deficit based on past events
\item Frequency of Urban Soil Moisture Drought Events
    \end{itemize}
    &   \begin{itemize}
    \item Urban Groundwater Drought deficit based on past events
    \item Average duration of Urban Groundwater Drought deficit based on past events
    \item Frequency of Standardized Groundwater Index (SGI)
        \end{itemize}                       \\
    \midrule
Sensitivity & Sensitivity                   \\
    \midrule
\emph{Physical characteristics} 
    &   \emph{Physical characteristics}     \\
    \begin{itemize}
\item Percentage of soils with high permeability
\item Percentage of urban agricultural area to total city area
\item Percentage of urban gardens, parks, forests to total city’s area
\item Percentage of parks which are irrigated
\item Percentage of parks whose plants\textbackslash{}trees require little water
\item Existence of risk-reduced services\\

\hspace{-\leftmargin}\emph{Political characteristics}
    \item Existence of regulations regarding where parks, urban gardens, urban forests, and urban agricultural areas can be created and what kind of vegetation, crops, and tress can be planted
    \end{itemize}
    &   \begin{itemize}
    \item Percentage of soils with high permeability
    \item Building density
    \item Percentage of building on wooden piles
    \item Percentage of cultural heritage buildings on wooden piles
    \item Locations of critical infrastructure (e.g. hospital, electricity station)
    \item Location of enterprises
    \item Groundwater extraction permits\\

\hspace{-\leftmargin}\emph{Social characteristics}
    \item Population density
    \item Percentage of minority population whose house is on wooden piles
    \item Financial status of residents whose house is on wooden piles (this could be in adaptive capacity as well)
     \item Existence of regulations regarding the way buildings ought to be erected  and type of materials ought to be used eradicating the use of wooden poles
    \end{itemize}   \\
    \midrule 
Adaptive Capacity   & Adaptive Capacity \\
    \midrule
\emph{Physical}     &   \emph{Physical} \\
    \begin{itemize}
\item Water availability for irrigation
\item Water harvesting for watering urban parks\\

\hspace{-\leftmargin}\emph{Socio-economic}
\item Unemployment rate (proxy for economic status)\\    

\hspace{-\leftmargin}\emph{Political}
\item Political status
\item Existence of Contingency plans
\item Availability of water trucks for that water function
\item Existence of institutions with relevant competencies
    \end{itemize}
    &   \begin{itemize}
    \item Infiltration mechanisms to recharge the groundwater table if needed\\

\hspace{-\leftmargin}\emph{Socio-economic}
    \item Educational level of residents (proxy for economic status) whose house is on wooden piles
    \item Gross domestic product if the analysis takes place for cities and not for neighborhoods
     \item Public Budget Expenditure of the city\\

\hspace{-\leftmargin}\emph{Political}
    \item Political status of the city
    \item Existence of institutions with relevant competences
        \end{itemize}   \\
    \bottomrule
    \end{tabularx}%
\end{table}
\end{document}

编辑: 如果文本区域边框较大(如上述 MWE 中定义的那样),则可以使用较小的字体大小,例如\smallsize ,并且 - 如果需要 - 还可以减小基线大小,例如使用\small\linespread{0.9}\selectfont

相关内容