【问题标题】:Not able to add footnote and caption below a table in Latex无法在 Latex 表格下方添加脚注和标题
【发布时间】:2021-06-17 13:42:23
【问题描述】:

我正在使用 tabularx 包创建表格,并在表格包中添加 figtext 和标题。我想要表格下方的脚注和标题,但只要我添加标题,脚注就会消失。我的代码如下:

main.tex 文件有以下代码

\documentclass[12pt]{article}

\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs}

\usepackage{ulem}

\usepackage{float}
\restylefloat{table}

\begin{frame}
\center
\input{MangoShare}
\label{mangoshare}
\end{frame}

MangoShare.tex 是被调用到 main.tex 的引用。

\begin{centre}
\begin{table}[h!]
\\[-1.8ex]\hline 
\hline \\\\[-1.8ex] 
%\renewcommand{\arraystretch}{1.8}
\begin{tabularx}{1\textwidth}{>{\raggedright\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X}
\small
\\[-1.8ex]
& & \multicolumn{6}{c}{Percentage Share} \\\\[-1.8ex]
\cline{3-8} \\[-1.8ex]
                 & &\multicolumn{1}{c}{A} &\multicolumn{1}{c}{B}   &\multicolumn{1}{c}{C}   &\multicolumn{1}{c}{D}   &\multicolumn{1}{c}{E}  &\multicolumn{1}{c}{F} \\
\midrule
\multicolumn{2}{l}{Mango} & 0.58 & 0.56 & 0.92 & 0.22 & 0.72 & 0.033 \\
\tiny
\end{tabularx}
\hline 
\hline %\\[-1.8ex]
\figtext{\\[-1.8ex]\emph{Notes:} Controls Used} \\[-1.8ex]
\caption{Mango Share}
\end{table}
\end{centre}

在这方面的任何帮助将不胜感激。非常感谢!

【问题讨论】:

  • 你能在一个单独的代码块中制作一个可编译的minimal reproducible example,这样我们就可以直接复制并尝试它,而不用把你的代码片段拼凑在一起吗?
  • 在过去的几周里,我已经多次看到\\[-1.8ex] 如此荒谬的用法。这是表生成器之类的程序的结果吗?
  • 不,这只是在 hline/cline 和行测试之间给了我所需的空间。而且,我还尝试编写可重现的代码。我不知何故觉得问题在于我如何在 main.tex 中调用表格

标签: latex tabular pdflatex tex latex-environment


【解决方案1】:

有几个问题:

  • table 是一个浮动环境,旨在在您的文档中移动以获得漂亮的输出。如果你将它包装在像centerframe 这样的静态环境中,它就无法做到这一点!

  • \hline 用于tabular 环境中的行,不要在外部使用它们(或者最好不要使用它们,booktab 包中的规则要好得多)

  • 将单元格包装成\multicolumn{1}... 删除所有这些不必要的命令是没有意义的。它们会破坏表格单元格的对齐方式

  • 不要在没有活动行的地方使用\\[-1.8ex]。他们会弄乱表格行等,请参阅Why are the vertical lines in my table different lengths?

  • 如果您想更改 tabular 的字体大小,请在外面执行此操作。

  • \figtext 未定义。

  • \cmidrule 提供比\cline 更好的间距

  • 浮动说明符[h!] 很可能会导致错误的图像放置,最好使用[htbp] 给乳胶更多选项

--

\documentclass[12pt]{article}

\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs}

\usepackage{ulem}

\usepackage{float}
\restylefloat{table}
\begin{document}

%\begin{frame}
%\center
%\begin{centre}
\begin{table}[htbp]
%\\[-1.8ex]\hline 
%\hline \\\\[-1.8ex] 
%\renewcommand{\arraystretch}{1.8}
\begin{tabularx}{1\textwidth}{@{}>{\raggedright\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X@{}}
%\small
%\\[-1.8ex]
& & \multicolumn{6}{c}{Percentage Share} \\%[-1.8ex]
\cmidrule{3-8} %\\[-1.8ex]
                 & &A &B   &C   &D   &E  &F \\
\midrule
\multicolumn{2}{@{}l}{Mango} & 0.58 & 0.56 & 0.92 & 0.22 & 0.72 & 0.033 \\
%\tiny
\end{tabularx}
%\hline 
%\hline %\\[-1.8ex]

\bigskip

\emph{Notes:} Controls Used

\caption{Mango Share}
\label{mangoshare}
\end{table}
%\end{centre}

%\end{frame}


\end{document}

【讨论】:

  • 非常感谢! :) 删除 figtext 和其他冗余代码有效! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-11-21
  • 1970-01-01
  • 1970-01-01
  • 2016-10-14
  • 1970-01-01
  • 1970-01-01
  • 2016-05-21
相关资源
最近更新 更多