使用 longtable 来显示图形:图形与水平线和垂直线重叠

使用 longtable 来显示图形:图形与水平线和垂直线重叠

我有大量的图表想要插入到 longtable 中来制作图表,可能长达几页。

但是,我无法缩放每个表格单元格内的图形,使它们不与表格中的水平线和垂直线重叠。如果我仅减小每个表格单元格的宽度,单元格和图形将缩小相同的倍数,而图形仍与线条重叠。

有人能帮助我更改代码以避免这种重叠吗?

此外,如何将“缺少图形”的文本水平和垂直地放置在单元格的中间?

提前致谢!

编辑:我无法在此窗口中正确格式化代码行。我使用 Ctr-K 和四个空格。如何正确执行此操作?

在此处输入图片描述

\documentclass[9pt,a4paper,twosided]{article}
\usepackage{longtable}
\usepackage{graphicx} 
\begin{document}
\begin{longtable}{|c|c|c|}
\caption{My caption for figures in longtable}
\label{figtab-1B}\\%
\hline
\multicolumn{3}{c}{The table heading of the first page}\\%
\hline
\endfirsthead
\multicolumn{3}{c}{\tablename\ \thetable\ -- \textit{Continued from last page}}\\%
\hline
\multicolumn{3}{c}{The table heading for the next pages}\\%
\hline
\endhead
\hline \hline
\multicolumn{3}{c}{\tablename\ \thetable\ -- \textit{To be continued on the next page}} \\%
\endfoot
\hline
\endlastfoot
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Alkalitet_til_pH_4_comma_5.jpg}&
figure lacking&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Ammonium_(NH4-N).jpg}\\%
\hline
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Arsen_(As)_comma_oppsluttet_ICP-MS.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Bly_(Pb)_comma_oppsluttet_ICP-MS.jpg}&
figure lacking\\
\hline
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Kadmium_(Cd)_comma_oppsluttet_ICP-MS.jpg}&
figure lacking&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Kobber_(Cu)_comma_oppsluttet_ICP-MS.jpg}\\%
\hline
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Krom_(Cr)_comma_oppsluttet_ICP-MS.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Krysen_slash_Trifenylen.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Naftalen.jpg}\\%
\hline
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Nikkel_(Ni)_comma_oppsluttet_ICP-MS.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Pyren.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Sink_(Zn)_comma_oppsluttet_ICP-MS.jpg}\\%
\hline
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Suspendert_stoff.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Total_Fosfor.jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Total_Nitrogen.jpg}\\%
\hline
\includegraphics[width=0.33\textwidth]{./figures/1B_- _Total_organisk_karbon_(TOC_slash_NPOC).jpg}&
\includegraphics[width=0.33\textwidth]{./figures/1B_-_Turbiditet.jpg}\\%
\end{longtable}
\end{document}

答案1

\documentclass[9pt,a4paper,twosided]{article}
\usepackage{longtable}
\usepackage[demo,
            export]{adjustbox}
\usepackage{etoolbox}

%-------------------------------------- only for show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.25pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begingroup
    \expandafter\patchcmd\csname Gin@ii\endcsname   % needed etoolbox
      {\setkeys{Gin}{#1}}%
      {\setkeys{Gin}%
          {width=0.3\linewidth,%                    % standard graphicx settings
           valign=c, margin=0pt 3pt 0pt 3pt,#1}%   % settings from adjustbox
      }
      {}{}
\setlength\tabcolsep{5pt}
\setlength\tabcolsep{3pt}
\begin{longtable}{|c|c|c|}
\caption{My caption for figures in longtable}
\label{figtab-1B}\\%
\hline
\multicolumn{3}{c}{The table heading of the first page}\\%
\hline
\endfirsthead
\multicolumn{3}{c}{\tablename\ \thetable\ -- \textit{Continued from last page}}\\%
\hline
\multicolumn{3}{c}{The table heading for the next pages}\\%
\hline
\endhead
\hline \hline
\multicolumn{3}{c}{\tablename\ \thetable\ -- \textit{To be continued on the next page}} \\%
\endfoot
\hline
\endlastfoot
\includegraphics{./figures/1B_-_Alkalitet_til_pH_4_comma_5.jpg}
    &   figure lacking
        &   \includegraphics{./figures/1B_-_Ammonium_(NH4-N).jpg}                       \\
    \hline
\includegraphics{./figures/1B_-_Arsen_(As)_comma_oppsluttet_ICP-MS.jpg}
    &   \includegraphics{./figures/1B_-_Bly_(Pb)_comma_oppsluttet_ICP-MS.jpg}
        &   figure lacking                                                              \\
\hline
\includegraphics{./figures/1B_-_Kadmium_(Cd)_comma_oppsluttet_ICP-MS.jpg}
    &   figure lacking
        &   \includegraphics{./figures/1B_-_Kobber_(Cu)_comma_oppsluttet_ICP-MS.jpg}    \\
\hline
\includegraphics{./figures/1B_-_Krom_(Cr)_comma_oppsluttet_ICP-MS.jpg}
    &   \includegraphics{./figures/1B_-_Krysen_slash_Trifenylen.jpg}
        &   \includegraphics{./figures/1B_-_Naftalen.jpg}                               \\
\hline
\includegraphics{./figures/1B_-_Nikkel_(Ni)_comma_oppsluttet_ICP-MS.jpg}
    &   \includegraphics{./figures/1B_-_Pyren.jpg}
        &   \includegraphics{./figures/1B_-_Sink_(Zn)_comma_oppsluttet_ICP-MS.jpg}      \\
\hline
\includegraphics{./figures/1B_-_Suspendert_stoff.jpg}
    &   \includegraphics{./figures/1B_-_Total_Fosfor.jpg}
        &   \includegraphics{./figures/1B_-_Total_Nitrogen.jpg}                         \\
\hline
\includegraphics{./figures/1B_- _Total_organisk_karbon_(TOC_slash_NPOC).jpg}
    &   \includegraphics{./figures/1B_-_Turbiditet.jpg}
        &                                                                               \\
\end{longtable}
\endgroup
\end{document}

在此处输入图片描述

答案2

将此添加到您的序言中:

\usepackage{cellspace}
\setlength{\cellspacetoplimit}{3pt}
\setlength{\cellspacebottomlimit}{3pt}

并且 longtable 代码的第一行是

\begin{longtable}{|Sc|Sc|Sc|}

(如果您加载siunitx替换ScCc)。

相关内容