某些 URL 链接和文本不会在 Latex 表中换行,而其他的则会换行

某些 URL 链接和文本不会在 Latex 表中换行,而其他的则会换行

我正在尝试使用 Latex 重新创建下表: 在此处输入图片描述

然而,在我尝试的过程中,我发现我的表格大小很奇怪,某些 URL 和文本不会在其单元格内换行,而其他的则换行,尽管命令相同。我想知道如何换行这些文本并压缩表格的大小,即使文本大小变小了。这是我的尝试:

\begin{table}[H]
   \centering
   \small
   \begin{tabular}{|p{3cm}|p{3.5cm}|p{3.5cm}|p{3.5cm}|}
       \hline
       Data Type & Data Names & GIS attribute Names & Data Source \\
       \hline
       Home Value & Change Rates of Zillow Home Value Index (ZHVI) 2020-2021 & C5\_20\_21 & Zillow Research Data: \url{https://www.zillow. com/research/data/} \\
       \hline
       \multirow{2}*{COVID 19 Data} & Case Number of Covid 19 by June 30, 2021 & COVID & \multirow{2}*{USA Facts: \url{https://usafacts.org/visualizations/coronavirus-covid-19-spread-map}}\\
       \cline{2-3}
       & Covid 19 Rate by June 30, 2021 & COVID\_R & \\
       \hline
       \multirow{18}*{Population, Employment, Education, Poverty, \& Other socio-economic data} & Total Population & POP & \multirow{11}*{U.S. Census Bureau: \url{https://covid19.census.gov/search?collection=Dataset}}\\
       \cline{2-3}
       & POP\_DENSITY & POP\_DENSITY &\\
       \cline{2-3}
       & Percent of Households with income in the past 12 months that was less than \$75,000 & HOUSELT75KP &\\
       \cline{2-3}
       & Total Population - Worked at home & POP\_WORK\_HOME &\\
       \cline{2-3}
       & Percent of Civilian Employed Population 16 Years and Over in Healthcare Practitioners and Technical Occupations & HCTOCC\_CALC &\\
       \cline{2-3}
       & Average Household Size & HOUSEHOLD\_SIZE &\\
       \cline{2-3}
       & Total Civilian Noninstitutionalized Population - With health insurance coverage & POP\_INSUR &\\
       \cline{2-3}
       & Percent of Population with No Health Insurance Coverage & POP\_NO\_INSUR &\\
       \cline{2-3}
       & Percent of Households with Internet At Home & PER\_INTERNET &\\
       \cline{2-3}
       & Total Households with a computer & HH\_COMPUTER &\\
       \cline{2-3}
       & Total Households with a broadband Internet subscription & HH\_INTERNET &\\
       \cline{2-4}
       & Number employed annual average, 2020 & EMPLOYED & \multirow{7}*{U.S. Department of Agriculture: \url{https://www.ers.usda.gov/data-products/county-level-data-sets/download-data/}}\\
       \cline{2-3}
       & Bachelor's degree or higher, 2015-19 & BACHELOR &\\
       \cline{2-3}
       & Percent of adults with a bachelor's degree or higher, 2015-19 & PER\_BACHELOR &\\
       \cline{2-3}
       & Estimate of people of all ages in poverty 2019 & POVALL &\\
       \cline{2-3}
       & Estimate of median household income 2019 & MEDHHINC &\\
       \cline{2-3}
       & Numeric Change in resident total population 7/1/2018 to 7/1/2019 & N\_POP\_CHG &\\
       \cline{2-3}
       & Natural increase of population in period 7/1/2018 to 6/30/2019 & NATURAL\_IN &\\
       \hline
       \end{tabular}
    \end{table}

在此处输入图片描述

答案1

使用xurl包和新表包tabularray可以轻松实现这一点。稍后提供多行单元格宏\SetCell[r=<number>]{<format>},结合X列类型可以拆分长\url文本。

由于表格很大,因此在表格中我使用\small字体大小:

\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{tabularray}
\usepackage{xurl}

\begin{document}
    \begin{table}
    \small
\begin{tblr}{% TABLE SPECIFICATION
    colspec={X[2,l] X[3,l]X[1.5,l]X[2,l]},
    hline{1,Z}={1pt}, hline{2}={0.7pt}, hline{3-Y},
    vlines,
             }
% TABLE BODY
Data Type 
    & Data Names
        & GIS attribute Names 
            & Data Source \\
Home Value 
    & Change Rates of Zillow Home Value Index (ZHVI) 2020-2021 
        & C5\_20\_21 
            & Zillow Research Data: \url{https://www.zillow. com/research/data/} \\

COVID 19 Data 
    & Case Number of Covid 19 by June 30, 2021 
        & COVID 
            & \SetCell[r=2]{h}Facts: \url{https://usafacts.org/visualizations/coronavirus-covid-19-spread-map}\\
   & Covid 19 Rate by June 30, 2021 & COVID\_R & \\
\SetCell[r=18]{h} Population, Employment, Education, Poverty, \& Other socio-economic data
    & Total Population 
        & POP 
            & \SetCell[r=11]{h} U.S. Census Bureau: \url{https://covid19.census.gov/search?collection=Dataset}\\
    & POP\_DENSITY 
        & POP\_DENSITY 
            &   \\
    & Percent of Households with income in the past 12 months that was less than \$75,000 
        & HOUSELT75KP 
            &   \\
    & Total Population - Worked at home 
        & POP\_WORK\_HOME 
            &   \\
    & Percent of Civilian Employed Population 16 Years and Over in Healthcare Practitioners and Technical Occupations
        & HCTOCC\_CALC 
            &   \\
     & Average Household Size 
        & HOUSEHOLD\_SIZE 
            &   \\
    & Total Civilian Noninstitutionalized Population - With health insurance coverage 
        & POP\_INSUR 
            &   \\
    & Percent of Population with No Health Insurance Coverage 
        & POP\_NO\_INSUR 
            &   \\
    & Percent of Households with Internet At Home 
        & PER\_INTERNET 
            &   \\
    & Total Households with a computer 
        & HH\_COMPUTER 
            &   \\
    & Total Households with a broadband Internet subscription
        & HH\_INTERNET 
            &   \\
    & Number employed annual average, 2020 
        & EMPLOYED 
            & \SetCell[r=7]{h} U.S. Department of Agriculture: \url{https://www.ers.usda.gov/data-products/county-level-data-sets/download-data/}  \\
    & Bachelor's degree or higher, 2015-19 
        & BACHELOR 
            &   \\
    & Percent of adults with a bachelor's degree or higher, 2015-19 
        & PER\_BACHELOR 
            &   \\
    & Estimate of people of all ages in poverty 2019 
        & POVALL 
            &   \\
    & Estimate of median household income 2019 
        & MEDHHINC 
            &   \\
    & Numeric Change in resident total population 7/1/2018 to 7/1/2019 
        & N\_POP\_CHG 
            &   \\
    & Natural increase of population in period 7/1/2018 to 6/30/2019 
        & NATURAL\_IN 
            &   \\
\end{tblr}
   \end{table}
\end{document}

在此处输入图片描述

相关内容