创建带有文本的 Latex 表格

创建带有文本的 Latex 表格

我应该如何将其转换为 Latex 中具有视觉吸引力的表格?现在它看起来像这样。但是,我发现很难找出如何使“缩写”和“来源”居中。另外,是否可以将字体变小,以便表格变小?

在此处输入图片描述

在此处输入图片描述

\begin{tblr}{ Q[l,b,wd=6cm] Q[b] Q[b] }
\toprule
Variables                             & Abbrevation & Source \\ 
\midrule
CO2 emissions (metric tons per capita). This is our dependent variable. It is a proxy of environmental degradation. & co2  & WDI    \\

GDP per capita (constant 2015 US\$). It is used as an independent variable.      & gdp\_pc         & WDI    \\ 

Energy use (kg of oil equivalent per capita). It is used as an independent variable.   & energy    & WDI    \\ 

Gender parity index (GPI), school enrollment, primary and secondary (gross). It is used as an independent variable.    & gpi       & WDI    \\ 

Labor force participation rate,female (\% of female population ages 15+). It is used as an independent variable.        & f\_labor\_15        & WDI    \\ 
\bottomrule
\end{tblr}

答案1

视觉吸引力因人而异。我可能会使用包并使用该包(此处用作库)tabularray设置表格样式:booktabs

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\begin{tblr}{ Q[l,b,wd=4cm] Q[b] Q[b] }
\toprule
Variables                             & Abbrevation & Source \\ 
\midrule
CO2 emission (metric tons per capita) & co2         & WDI    \\
Second                                & aaa         & bbb    \\ 
Third                                 & ccc         & ddd    \\ 
Fourth                                & fff         & ggg    \\ 
Fifth                                 & hhh         & iii    \\ 
\bottomrule
\end{tblr}
\end{document}

在此处输入图片描述


b将列定义中的选项更改为 后m,单元格内容将围绕中心垂直对齐。至于减小字体大小或设置文本样式,有多种选项,具体取决于您想要设置样式的内容,仅设置部分文本或整个列:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\begin{tblr}{ Q[l,m,wd=4cm] Q[m,font=\footnotesize] Q[m] }
\toprule
Variables                             & Abbrevation & Source \\ 
\midrule
CO2 emission {\footnotesize(\textbf{metric tons} per capita)} 
                                      & co2         & WDI    \\
Second                                & aaa         & bbb    \\ 
Third                                 & ccc         & ddd    \\ 
Fourth                                & fff         & ggg    \\ 
Fifth                                 & hhh         & iii    \\ 
\bottomrule
\end{tblr}
\end{document}

在此处输入图片描述

答案2

@Jasper Habicht 答案中的第二个例子只有很小的变化,而且大多与主题无关。

在此处输入图片描述

\documentclass{article}
\usepackage{newtxtext}          % added
\usepackage[version=4]{mhchem}  % added
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\begin{tblr}{colspec = {@{} X[j,m] Q[l] Q[l] @{}}, % <---
             }
    \toprule
Variables   & Abbreviation & Source \\
    \midrule
\ce{CO2} emissions (metric tons per capita). This is our dependent variable. It is a proxy of environmental degradation.
            & \ce{CO2}      & WDI    \\

GDP per capita (constant 2015 US\$). It is used as an independent variable.      
            & gdp\_pc       & WDI    \\

Energy use (kg of oil equivalent per capita). It is used as an independent variable.   
            & energy        & WDI    \\
Gender parity index (GPI), school enrollment, primary and secondary (gross). It is used as an independent variable.    
            & gpi           & WDI   \\
Labor force participation rate,female (\% of female population ages 15+). It is used as an independent variable.        
            & f\_labor\_15  & WDI    \\
    \bottomrule
\end{tblr}
\end{document}

相关内容