以正确的顺序排列表格和图片

以正确的顺序排列表格和图片

我无法按正确的顺序排列我的图表和表格。它们似乎以一种看似随机的方式出现在文档中。这是我使用的代码:

\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}

\begin{document}
...

\appendix
\section*{Appendix A: Figures and Tables}
\begin{figure}[h!]
\centering
\caption{Relationship Between GDP per Capita and Mean Tariff Rates}
\includegraphics[width=0.7\linewidth]{gdpscatter}
\label{fig:gdpscatter}
\end{figure}

\begin{figure}[h!]
\centering
\caption[]{Low Income Countries Mean Tariff Rates}
\label{fig:lowinchist}
\includegraphics[width=0.7\linewidth]{lowinchist}
\end{figure}

\begin{figure}[h!]
\centering
\caption[]{High Income Countries Mean Tariff Rates}
\label{fig:upinchist}
\includegraphics[width=0.7\linewidth]{upinchist}
\end{figure}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Results\label{tab1}}
\begin{tabular}{l*{3}{c}}
    \hline\hline
    &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}\\
    &\multicolumn{1}{c}{LN GDP Per Cap}&\multicolumn{1}{c}{LN GDP Per Cap}&\multicolumn{1}{c}{LN GDP Per Cap}\\
    \hline
    Tariff&    0.662\sym{***}&    0.260\sym{***}&    0.232\sym{***}\\
    & (0.0250)         & (0.0234)         & (0.0227)         \\
    [1em]
    Propright&                  &    0.276\sym{***}&    0.182\sym{***}\\
    &                  & (0.0179)         & (0.0220)         \\
    [1em]
    Govtcon&                  &   -0.162\sym{***}&   -0.135\sym{***}\\
    &                  & (0.0104)         & (0.0101)         \\
    [1em]
    Forex&                  &   0.0754\sym{***}&   0.0702\sym{***}\\
    &                  &(0.00611)         &(0.00586)         \\
    [1em]
    Moneygrowth    &                  &   0.0344\sym{*}  &  0.00939         \\
    &                  & (0.0145)         & (0.0144)         \\
    [1em]
    Bribes&                  &    0.120\sym{***}&    0.269\sym{***}\\
    &                  & (0.0177)         & (0.0228)         \\
    [1em]
    Constant        &    2.999\sym{***}&    4.368\sym{***}&    4.010\sym{***}\\
    &  (0.206)         &  (0.220)         &  (0.238)         \\
    Fixed Effects & No & No & Yes\\
    \hline
    Observations    &     2033         &     1753         &     1753         \\
    \hline\hline
    \multicolumn{4}{l}{\footnotesize Standard errors in parentheses}\\
    \multicolumn{4}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular}
\end{table}

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Results by Country Income Level\label{tab2}}
\begin{tabular}{l*{4}{c}}
    \hline\hline
    &\multicolumn{1}{c}{(Low)}&\multicolumn{1}{c}{(Low-Middle)}&\multicolumn{1}{c}{(Upper-Middle)}&\multicolumn{1}{c}{(Upper)}\\
    &\multicolumn{1}{c}{LN GDP Per Cap}&\multicolumn{1}{c}{LN GDP Per Cap}&\multicolumn{1}{c}{LN GDP Per Cap}&\multicolumn{1}{c}{LN GDP Per Cap}\\
    \hline
    Tariff&    0.110\sym{***}&   0.0652\sym{**} &  0.00176         &  -0.0184         \\
    & (0.0299)         & (0.0203)         & (0.0180)         & (0.0375)         \\
    [1em]
    Propright&   0.0397         &   0.0297         &   0.0375         &    0.193\sym{***}\\
    & (0.0291)         & (0.0229)         & (0.0192)         & (0.0232)         \\
    [1em]
    Govtcon&   0.0237         &  0.00742         &  -0.0250\sym{*}  &  -0.0365\sym{***}\\
    & (0.0155)         & (0.0107)         &(0.00980)         &(0.00801)         \\
    [1em]
    Forex& -0.00707         &-0.000292         &   0.0203\sym{***}&  -0.0135         \\
    &(0.00682)         &(0.00502)         &(0.00499)         & (0.0109)         \\
    [1em]
    Moneygrowth    &   0.0184         &  -0.0248         &  -0.0221         &   0.0119         \\
    & (0.0149)         & (0.0135)         & (0.0122)         & (0.0199)         \\
    [1em]
    Bribes&  -0.0184         &    0.162\sym{***}& -0.00570         &   0.0747\sym{***}\\
    & (0.0312)         & (0.0244)         & (0.0227)         & (0.0208)         \\
    [1em]
    Constant        &    5.431\sym{***}&    6.282\sym{***}&    8.758\sym{***}&    8.307\sym{***}\\
    &  (0.323)         &  (0.240)         &  (0.201)         &  (0.367)         \\
    \hline
    Observations    &      297         &      457         &      416         &      583         \\
    \hline\hline
    \multicolumn{5}{l}{\footnotesize Standard errors in parentheses}\\
    \multicolumn{5}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular}
\end{table}
\end{document}

但是,在文档本身中,它显示前两个图,然后是表格,然后是最后一个图。我希望​​先显示所有图,然后是所有表格。我尝试将其分成两个单独的附录,但这只会产生更多格式问题(在图 3 的末尾,在同一页上,它将开始附录 B,但随后会出现很多尴尬的空白,因为表格放不下,我无法摆脱它来拯救我的生命)。

答案1

  • 您提供的信息不足,我们无法重现您在 MWE 中遇到的问题。请参阅米科上述评论。
  • 使用example-image fromMWE 中的 graphicx` 包,我无法重现您的问题。图像和表格的顺序始终与插入文档的顺序相同
  • 离题:如果你使用booktabs表格水平规则包和S列类型来siunitx对齐小数点处的数字,你的表格看起来会更美观

    考虑到上述建议,我改变了你的 MWE。看看这对你来说是否可接受,以及在它的帮助下,你是否可以构建 MWE 来演示你的问题(例如,定义示例图像的高度)

\documentclass[12pt]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{siunitx}            % added
\sisetup{input-symbols = {()},
         table-space-text-post=\sym{***},%
         table-align-text-post=false,
         }

\usepackage{booktabs}           % added
\usepackage[skip=1ex]{caption}  % added

\begin{document}
...

\appendix
\section*{Appendix A: Figures and Tables}
    \begin{figure}[htp]  % changed
\centering
\caption{Relationship Between GDP per Capita and Mean Tariff Rates}
\includegraphics[width=1\linewidth]{example-image-a}
\label{fig:gdpscatter}
    \end{figure}

    \begin{figure}[htp]  % changed
\centering
\caption[]{Low Income Countries Mean Tariff Rates}
\label{fig:lowinchist}
\includegraphics[width=1\linewidth]{example-image-b}
    \end{figure}

    \begin{figure}[htp]  % changed
\centering
\caption[]{High Income Countries Mean Tariff Rates}
\label{fig:upinchist}
\includegraphics[width=1\linewidth]{example-image-c}
    \end{figure}


    \begin{table}[htp]\centering  % changed
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Results\label{tab1}}
\begin{tabular}{l*{3}{S[table-format=1.4]}}  % changed
    \toprule
        &   \multicolumn{3}{c}{LN GDP Per Cap}                      \\
    \cmidrule(lr){2-4}
        &   {(1)}                   &   {(2)}           &  {(3)}    \\
    \midrule
Tariff  &   0.662\sym{***}  &   0.260\sym{***}  &   0.232\sym{***}  \\
        &   (0.0250)        &   (0.0234)        &   (0.0227)        \\
    \addlinespace
Propright   &               &    0.276\sym{***} &   0.182\sym{***}  \\
            &               &   (0.0179)        &   (0.0220)        \\
    \addlinespace
Govtcon     &               &   -0.162\sym{***} &    -0.135\sym{***}\\
            &               &   (0.0104)        &   (0.0101)        \\
    \addlinespace
Forex       &               &   0.0754\sym{***} &   0.0702\sym{***} \\
            &               &   (0.00611)       &   (0.00586)       \\
    \addlinespace
Moneygrowth &               &   0.0344\sym{*}   &   0.00939         \\
            &               &   (0.0145)        &   (0.0144)        \\
    \addlinespace
Bribes      &               &   0.120\sym{***}  &   0.269\sym{***}  \\
            &               &   (0.0177)        & (0.0228)          \\
    \addlinespace
Constant    &   2.999\sym{***}  &   4.368\sym{***}  &   4.010\sym{***}  \\
            &  (0.206)          &  (0.220)          &  (0.238)          \\
Fixed Effects   &   {No}    &   {No}            &   {Yes}           \\
    \midrule
Observations    &   {2033}  &   {1753}          &   {1753}          \\
    \bottomrule
    \multicolumn{4}{l}{\footnotesize Standard errors in parentheses}              \\
    \multicolumn{4}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}
\end{tabular}
    \end{table}

    \begin{table}[htp]\centering  % changed
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Results by Country Income Level\label{tab2}}
\begin{tabular}{l*{4}{S[table-format=-1.5]}}  % changed
    \toprule
        &   \multicolumn{4}{c}{LN GDP Per Cap}                                          \\
    \cmidrule(lr){2-5}
    \cmidrule(lr){2-4}
        &   {(1)}           &   {(2)}           &   {(3)}           &   {(4)}           \\
    \midrule
Tariff  &   0.110\sym{***}  &   0.0652\sym{**}  &   0.00176         &   -0.0184         \\
        &   (0.0299)        &   (0.0203)        &   (0.0180)        &   (0.0375)        \\
    \addlinespace
Propright
        &   0.0397          &   0.0297          &   0.0375          &   0.193\sym{***}  \\
        &   (0.0291)        &   (0.0229)        &   (0.0192)        &   (0.0232)        \\
    \addlinespace
Govtcon &   0.0237          &   0.00742         &  -0.0250\sym{*}   &   -0.0365\sym{***}\\
        &   (0.0155)        &   (0.0107)        &   (0.00980)       &   (0.00801)       \\
    \addlinespace
Forex   &   -0.00707        &   -0.000292       &   0.0203\sym{***} &  -0.0135          \\
        &   (0.00682)       &   (0.00502)       &   (0.00499)       &   (0.0109)        \\
    \addlinespace
Moneygrowth
        &   0.0184          &  -0.0248          &   -0.0221         &   0.0119          \\
        &   (0.0149)        &   (0.0135)        &   (0.0122)        &   (0.0199)        \\
    \addlinespace
Bribes  &   -0.0184         &   0.162\sym{***}  &   -0.00570        &   0.0747\sym{***} \\
        &   (0.0312)        &   (0.0244)        &   (0.0227)        &   (0.0208)        \\
    \addlinespace
Constant&   5.431\sym{***}  &   6.282\sym{***}  &   8.758\sym{***}  &   8.307\sym{***}  \\
        &  (0.323)          &   (0.240)         &   (0.201)         &   (0.367)         \\
    \midrule
Observations
        &   {297}           &   {457}           &   {416}           &   {583}           \\
    \bottomrule
    \multicolumn{5}{l}{\footnotesize Standard errors in parentheses}\\
    \multicolumn{5}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular}
    \end{table}
\end{document}

以上 MWE 生成了五页长的文档。前三页包含图像,后两页包含表格。

相关内容