删除 latex 中 xtable 中的多余空间

删除 latex 中 xtable 中的多余空间

下表中要么没有空格,要么有空格,要么有很多空格,问题在于对齐{p{}}?如何只留一个空格。

\documentclass[11pt,authoryear,1p,times,sort&compress]{elsarticle}
\begin{document}

\begin{table}[ht]
\centering
\footnotesize
\begin{tabular}{p{0.1cm} p{3.5cm} p{0.4cm} p{7cm} p{0.7cm} p{0.75cm} p{0.7cm} p{0.75cm} } 
  %\toprule
    \hline
 & Author(s) Name & Year &  Title & TLC & TLC/t & TGC & TGC/t \\ 
  \hline
1 & Allen F; Demirguc-Kunt A; Klapper L; Peria Msm & 2016 & The Foundations Of Financial Inclusion: Understanding Ownership And Use Of Formal Accounts &  11 & 2.20 &  59 & 11.80 \\ 
  2 & Aterido R; Beck T; Iacovone L & 2013 & Access To Finance In Sub-Saharan Africa: Is There A Gender Gap? &  16 & 2.00 &  54 & 6.75 \\ 
  3 & Claessens S; Feijen E; Laeven L & 2008 & Political Connections And Preferential Access To Finance: The Role Of Campaign Contributions &  25 & 1.92 & 442 & 34.00 \\ 
  4 & Alesina Af; Lotti F; Mistrulli Pe & 2013 & Do Women Pay More For Credit? Evidence From Italy &  15 & 1.88 &  63 & 7.88 \\ 
  5 & Fungacova Z; Weill L & 2015 & Understanding Financial Inclusion In China &  10 & 1.67 &  35 & 5.83 \\ 
  6 & Blanchflower Dg; Levine Pb; Zimmerman Dj & 2003 & Discrimination In The Small-Business Credit Market &  29 & 1.61 & 224 & 12.44 \\ 
  7 & Ghosh S; Vinod D & 2017 & What Constrains Financial Inclusion For Women? Evidence From Indian Micro Data &   6 & 1.50 &  16 & 4.00 \\ 
  8 & Asiedu E; Kalonda-Kanyama I; Ndikumana L; Nti-Addae A & 2013 & Access To Credit By Firms In Sub-Saharan Africa: How Relevant Is Gender? &  11 & 1.38 &  28 & 3.50 \\ 
  9 & Asiedu E; Freeman Ja; Nti-Addae A & 2012 & Access To Credit By Small Businesses: How Relevant Are Race, Ethnicity, And Gender? &  11 & 1.22 &  28 & 3.11 \\ 
  10 & Luan Dx; Bauer S & 2016 & Does Credit Access Affect Household Income Homogeneously Across Different Groups Of Credit Recipients? Evidence From Rural Vietnam &   6 & 1.20 &  12 & 2.40 \\
    \hline
      \end{tabular}
\caption{caption}
%significance: $^*p<0.1;~^{**}p<0.05;~^{***}p<0.01$. }
\label{tab:mytab}
\end{table}

\end{document}

问题看起来像这样

预期结果

text1 text2; text3 text4

提前谢谢了

答案1

这是表格的三个版本。在第一个版本中,我只是添加了,>{\raggedright\arraybackslash}以便获得左对齐而不是两端对齐的列。在第二个和第三个示例中,我添加了booktabssiunitx和,tabularx以使表格适合可用的文本宽度,并改善表格的对齐和整体可读性。

\documentclass[11pt,authoryear,1p,times,sort&compress]{elsarticle}
\usepackage{array} % used for the first version 

\usepackage{booktabs} % horizontal lines with improved spacing in the second example
\usepackage{tabularx} %for tabularx environment and X type columns in second example
\usepackage{siunitx} %for S type columns and improved alignment of numbers in second example.

\usepackage{pdflscape} % For landscape page in third example
\begin{document}

\begin{table}[ht]
\centering
\footnotesize
\begin{tabular}{l >{\raggedright\arraybackslash}p{3.5cm} l p{7cm} llll } 
  %\toprule
    \hline
 & Author(s) Name & Year &  Title & TLC & TLC/t & TGC & TGC/t \\ 
  \hline
1 & Allen F; Demirguc-Kunt A; Klapper L; Peria Msm & 2016 & The Foundations Of Financial Inclusion: Understanding Ownership And Use Of Formal Accounts &  11 & 2.20 &  59 & 11.80 \\ 
  2 & Aterido R; Beck T; Iacovone L & 2013 & Access To Finance In Sub-Saharan Africa: Is There A Gender Gap? &  16 & 2.00 &  54 & 6.75 \\ 
  3 & Claessens S; Feijen E; Laeven L & 2008 & Political Connections And Preferential Access To Finance: The Role Of Campaign Contributions &  25 & 1.92 & 442 & 34.00 \\ 
  4 & Alesina Af; Lotti F; Mistrulli Pe & 2013 & Do Women Pay More For Credit? Evidence From Italy &  15 & 1.88 &  63 & 7.88 \\ 
  5 & Fungacova Z; Weill L & 2015 & Understanding Financial Inclusion In China &  10 & 1.67 &  35 & 5.83 \\ 
  6 & Blanchflower Dg; Levine Pb; Zimmerman Dj & 2003 & Discrimination In The Small-Business Credit Market &  29 & 1.61 & 224 & 12.44 \\ 
  7 & Ghosh S; Vinod D & 2017 & What Constrains Financial Inclusion For Women? Evidence From Indian Micro Data &   6 & 1.50 &  16 & 4.00 \\ 
  8 & Asiedu E; Kalonda-Kanyama I; Ndikumana L; Nti-Addae A & 2013 & Access To Credit By Firms In Sub-Saharan Africa: How Relevant Is Gender? &  11 & 1.38 &  28 & 3.50 \\ 
  9 & Asiedu E; Freeman Ja; Nti-Addae A & 2012 & Access To Credit By Small Businesses: How Relevant Are Race, Ethnicity, And Gender? &  11 & 1.22 &  28 & 3.11 \\ 
  10 & Luan Dx; Bauer S & 2016 & Does Credit Access Affect Household Income Homogeneously Across Different Groups Of Credit Recipients? Evidence From Rural Vietnam &   6 & 1.20 &  12 & 2.40 \\
    \hline
      \end{tabular}
\caption{caption}
%significance: $^*p<0.1;~^{**}p<0.05;~^{***}p<0.01$. }
\label{tab:mytab}
\end{table}


\begin{table}[ht]
\centering
\footnotesize
\setlength{\tabcolsep}{4pt}
\begin{tabularx}{\textwidth}{l 
                             >{\raggedright\arraybackslash}p{2.5cm} 
                             l 
                             >{\raggedright\arraybackslash}X 
                             S[table-format=2] 
                             S[table-format=1.2]
                             S[table-format=3]
                             S[table-format=2.2] } 
  \toprule
 & Author(s) Name & Year &  Title & {TLC} & {TLC/t} & {TGC} & {TGC/t} \\ 
  \midrule
1 & Allen F; Demirguc-Kunt A; Klapper L; Peria Msm & 2016 & The Foundations Of Financial Inclusion: Understanding Ownership And Use Of Formal Accounts &  11 & 2.20 &  59 & 11.80 \\  \addlinespace
  2 & Aterido R; Beck T; Iacovone L & 2013 & Access To Finance In Sub-Saharan Africa: Is There A Gender Gap? &  16 & 2.00 &  54 & 6.75 \\ \addlinespace
  3 & Claessens S; Feijen E; Laeven L & 2008 & Political Connections And Preferential Access To Finance: The Role Of Campaign Contributions &  25 & 1.92 & 442 & 34.00 \\ \addlinespace
  4 & Alesina Af; Lotti F; Mistrulli Pe & 2013 & Do Women Pay More For Credit? Evidence From Italy &  15 & 1.88 &  63 & 7.88 \\ \addlinespace
  5 & Fungacova Z; Weill L & 2015 & Understanding Financial Inclusion In China &  10 & 1.67 &  35 & 5.83 \\ \addlinespace
  6 & Blanchflower Dg; Levine Pb; Zimmerman Dj & 2003 & Discrimination In The Small-Business Credit Market &  29 & 1.61 & 224 & 12.44 \\ \addlinespace
  7 & Ghosh S; Vinod D & 2017 & What Constrains Financial Inclusion For Women? Evidence From Indian Micro Data &   6 & 1.50 &  16 & 4.00 \\ \addlinespace
  8 & Asiedu E; Kalonda-Kanyama I; Ndikumana L; Nti-Addae A & 2013 & Access To Credit By Firms In Sub-Saharan Africa: How Relevant Is Gender? &  11 & 1.38 &  28 & 3.50 \\ \addlinespace
  9 & Asiedu E; Freeman Ja; Nti-Addae A & 2012 & Access To Credit By Small Businesses: How Relevant Are Race, Ethnicity, And Gender? &  11 & 1.22 &  28 & 3.11 \\ \addlinespace
  10 & Luan Dx; Bauer S & 2016 & Does Credit Access Affect Household Income Homogeneously Across Different Groups Of Credit Recipients? Evidence From Rural Vietnam &   6 & 1.20 &  12 & 2.40 \\
    \bottomrule
      \end{tabularx}
\caption{caption}
%significance: $^*p<0.1;~^{**}p<0.05;~^{***}p<0.01$. }
\label{tab:mytab}
\end{table}

\begin{landscape}
\begin{table}[ht]
\centering
\footnotesize
\begin{tabularx}{\linewidth}{l 
                             >{\raggedright\arraybackslash}p{4.25cm} 
                             l 
                             >{\raggedright\arraybackslash}X 
                             S[table-format=2] 
                             S[table-format=1.2]
                             S[table-format=3]
                             S[table-format=2.2] } 
  \toprule
 & Author(s) Name & Year &  Title & {TLC} & {TLC/t} & {TGC} & {TGC/t} \\ 
  \midrule
1 & Allen F; Demirguc-Kunt A; Klapper L; Peria Msm & 2016 & The Foundations Of Financial Inclusion: Understanding Ownership And Use Of Formal Accounts &  11 & 2.20 &  59 & 11.80 \\ \addlinespace 
  2 & Aterido R; Beck T; Iacovone L & 2013 & Access To Finance In Sub-Saharan Africa: Is There A Gender Gap? &  16 & 2.00 &  54 & 6.75 \\ \addlinespace
  3 & Claessens S; Feijen E; Laeven L & 2008 & Political Connections And Preferential Access To Finance: The Role Of Campaign Contributions &  25 & 1.92 & 442 & 34.00 \\ \addlinespace
  4 & Alesina Af; Lotti F; Mistrulli Pe & 2013 & Do Women Pay More For Credit? Evidence From Italy &  15 & 1.88 &  63 & 7.88 \\ \addlinespace
  5 & Fungacova Z; Weill L & 2015 & Understanding Financial Inclusion In China &  10 & 1.67 &  35 & 5.83 \\ \addlinespace
  6 & Blanchflower Dg; Levine Pb; Zimmerman Dj & 2003 & Discrimination In The Small-Business Credit Market &  29 & 1.61 & 224 & 12.44 \\ \addlinespace
  7 & Ghosh S; Vinod D & 2017 & What Constrains Financial Inclusion For Women? Evidence From Indian Micro Data &   6 & 1.50 &  16 & 4.00 \\ \addlinespace
  8 & Asiedu E; Kalonda-Kanyama I; Ndikumana L; Nti-Addae A & 2013 & Access To Credit By Firms In Sub-Saharan Africa: How Relevant Is Gender? &  11 & 1.38 &  28 & 3.50 \\ \addlinespace
  9 & Asiedu E; Freeman Ja; Nti-Addae A & 2012 & Access To Credit By Small Businesses: How Relevant Are Race, Ethnicity, And Gender? &  11 & 1.22 &  28 & 3.11 \\ \addlinespace
  10 & Luan Dx; Bauer S & 2016 & Does Credit Access Affect Household Income Homogeneously Across Different Groups Of Credit Recipients? Evidence From Rural Vietnam &   6 & 1.20 &  12 & 2.40 \\
    \bottomrule
      \end{tabularx}
\caption{caption}
%significance: $^*p<0.1;~^{**}p<0.05;~^{***}p<0.01$. }
\label{tab:mytab}
\end{table}
\end{landscape}
\end{document}

相关内容