我一直在努力解决这个问题,试图让它正常工作。我有一组复杂的长表,我想让它正确显示。
我想要做的是将目录编在一起。我的做法是,如果有些组共享同一张图片,我只想在第一个表格上方显示图片,前提是这些组出现在同一页上。如果表格跨越到下一页,或者如果有另一个组共享同一张图片,然后出现在下一页上,我希望它再次显示在顶部组的正上方。
我正在使用 PHP 生成 tex 代码,它会检查各组是否使用相同的图像,如果满足这些参数,则不会显示该图像。除了第 1 种情况外,我在其他所有情况下都能正常工作,第 1 种情况是,当具有相同图像的新组被推到新页面时,因为新页面不适合。我不知道如何“以编程方式”检测它现在在新页面上,因此需要显示图像。我正在尝试使用 AddEverypageHook 设置一个标志,它可以工作,但必须在生成表格后设置它,因为图像反而会出现在后面的表格中。这很有意义,因为我怀疑它首先生成表格,确定它需要新页面并推入它,然后设置标志(这意味着它在插入图像所需的点之后设置了标志)。我有一些代码可以生成一个 PDF,显示我正在尝试做的事情。
在此示例中,所有产品组都共享同一张图片,因此应显示图片的唯一表格应该是每页的第一个表格。但情况并非总是如此。如果另一个组使用不同的图片,它将显示在具有新图片的新组上方(继续在同一页面上),因此显示的图片并不总是顶部图片。生成后(可能需要运行几次才能正确生成所有数据),如果您查看第 4 页,您会注意到它没有显示在第一个组上方,但显示在第二个组上方。
\documentclass[8pt]{report}
\usepackage[demo]{graphicx}
\usepackage[final]{pdfpages}
\usepackage{fancyhdr}
\usepackage[letterpaper, margin=1in]{geometry}
\usepackage{caption}
\usepackage{tocloft}
\usepackage[export]{adjustbox}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{helvet}
\usepackage{everypage}
\renewcommand{\familydefault}{\sfdefault}
\hypersetup{%
pdfborder = {0 0 0}
}
\setcounter{tocdepth}{5}
\pagestyle{fancy}
\renewcommand\footrule{\begin{minipage}{1\textwidth}
\hrule width \hsize height 2pt \kern 1mm \hrule width \hsize
\end{minipage}\par}%
\lfoot{\today}
\rfoot{\thepage}
\cfoot{}
\rhead{}
\lhead{\leftmark}
\renewcommand {\headrulewidth}{0.4pt}
\renewcommand {\footrulewidth}{0.4pt}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\captionsetup{labelsep=space,singlelinecheck=off,labelformat=empty,labelfont=bf}
%
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
%
\newif\ifimportant\importantfalse
\AddEverypageHook{
\global\importanttrue
}
\begin{document}\thispagestyle{empty}
\setlength\unitlength{1in}
\begin{titlepage}
\begin{center}
\includegraphics[width=.5\textwidth]{}~\\[1cm]
\huge
{\fontsize{50}{60}\selectfont Product Catalog}\\
\vspace{.25in}
{\fontsize{30}{40}\selectfont DOUG PETERSON}\\
\vspace{.25in}
{\fontsize{20}{30}\selectfont \today}
\vfill
% Bottom of the page
{\large www.contractorshvacsupply.com}
\end{center}
\end{titlepage}
\setcounter{page}{2}
\tableofcontents
\includepdfset{pagecommand=\thispagestyle{fancy}}
\clearpage\phantomsection
\addcontentsline{toc}{chapter}{Residential Heating \& Cooling Equipment}
\markboth{Residential Heating \& Cooling Equipment}{}
\clearpage\phantomsection
\addcontentsline{toc}{section}{Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 92\% Legacy Single-Stage--912BA}
\global\importanttrue
\begin{longtable}{|p{.625in}|p{1.5in}|p{2.75in}|p{.875in}|}
\caption{
\ifimportant
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
\fi
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 92\% Legacy Single-Stage--912BA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 92\% Legacy Single-Stage--912BA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endhead
394688 & 912SB48100S21 & 912SB48100S21 1STG 92 FURNACE & \$1285.43 ea\\\hline
\end{longtable}
\addcontentsline{toc}{section}{Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Legacy Single-Stage--915SA}
\begin{longtable}{|p{.625in}|p{1.5in}|p{2.75in}|p{.875in}|}
\caption{
\ifimportant
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
\fi
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Legacy Single-Stage--915SA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Legacy Single-Stage--915SA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endhead
328431 & 915SA30040S14 & 915SA30040S14 1STG 95 FURNACE & \$1183.96 ea\\\hline
404315 & 915SA36040S17 & 915SA36040S17 1STG 95 FURNACE & \$1194.63 ea\\\hline
330654 & 915SA42060S17 & 915SA42060S17 1STG 95 FURNACE & \$1224.64 ea\\\hline
330662 & 915SA42100S21 & 915SA42100S21 1STG 95 FURNACE & \$1355.81 ea\\\hline
330658 & 915SA48080S17 & 915SA48080S17 1STG 95 FURNACE & \$1314.06 ea\\\hline
330661 & 915SA60080S21 & 915SA60080S21 1STG 95 FURNACE & \$1328.39 ea\\\hline
330665 & 915SA60100S21 & 915SA60100S21 1STG 95 FURNACE & \$1372.00 ea\\\hline
330666 & 915SA60120S24 & 915SA60120S24 1STG 95 FURNACE & \$1411.96 ea\\\hline
330668 & 915SA60140S24 & 915SA60140S24 1STG 95 FURNACE & \$1444.31 ea\\\hline
\end{longtable}
\addcontentsline{toc}{section}{Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Preferred Single-Stage ECM--925SA}
\begin{longtable}{|p{.625in}|p{1.5in}|p{2.75in}|p{.875in}|}
\caption{
\ifimportant
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
\fi
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Preferred Single-Stage ECM--925SA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Preferred Single-Stage ECM--925SA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endhead
210145 & 925SA30040E14 & 925SA30040E14 1STG ECM FURNACE & \$1233.76 ea\\\hline
210244 & 925SA42060E17 & 925SA42060E17 1STG ECM FURNACE & \$1315.63 ea\\\hline
210687 & 925SA48080E17 & 925SA48080E17 1STG ECM FURNACE & \$1446.71 ea\\\hline
210908 & 925SA48100E21 & 925SA48100E21 1STG ECM FURNACE & \$1520.87 ea\\\hline
211134 & 925SA66120E24 & 925SA66120E24 1STG ECM FURNACE & \$1595.16 ea\\\hline
\end{longtable}
\addcontentsline{toc}{section}{Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Preferred Two-Stage ECM--925TA}
\begin{longtable}{|p{.625in}|p{1.5in}|p{2.75in}|p{.875in}|}
\caption{
\ifimportant
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
\fi
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Preferred Two-Stage ECM--925TA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 95\% Preferred Two-Stage ECM--925TA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endhead
335968 & 925TA60100E21 & 925TA60100E21 2STG ECM FURNACE & \$1818.50 ea\\\hline
212066 & 925TA66120E24 & 925TA66120E24 2STG ECM FURNACE PLEASE SEE 986TB & \$2020.93 ea\\\hline
\end{longtable}
\addcontentsline{toc}{section}{Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 96\% Evolution Two-Stage Variable--986T}
\begin{longtable}{|p{.625in}|p{1.5in}|p{2.75in}|p{.875in}|}
\caption{
\ifimportant
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
\fi
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 96\% Evolution Two-Stage Variable--986T}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 96\% Evolution Two-Stage Variable--986T}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endhead
213086 & 986TA66120V24 & 986TA66120V24 EVO 2STG VS FURNACE & \$2104.24 ea\\\hline
448615 & 986TB42060V17 & 986TB42060V17 EVO 2STG VS FURNACE & \$1734.14 ea\\\hline
448616 & 986TB42080V17 & 986TB42080V17 EVO 2STG VS FURNACE & \$1796.61 ea\\\hline
448629 & 986TB60080V21 & 986TB60080V21 EVO 2STG VS FURNACE & \$1837.86 ea\\\hline
448661 & 986TB66100V21 & 986TB66100V21 EVO 2STG VS FURNACE & \$2065.30 ea\\\hline
448662 & 986TB66120V24 & 986TB66120V24 EVO 2STG VS FURNACE & \$2217.87 ea\\\hline
\end{longtable}
\addcontentsline{toc}{section}{Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 97\% Evolution Modulating Variable--987MA}
\begin{longtable}{|p{.625in}|p{1.5in}|p{2.75in}|p{.875in}|}
\caption{
\ifimportant
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
\fi
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 97\% Evolution Modulating Variable--987MA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endfirsthead
\caption[]{
\protect\includegraphics[width=1.875in,height=1.875in,keepaspectratio,right]{}
\global\importantfalse
Bryant Residential - Bryant Furnaces - Bryant High Effciency Furnaces - 97\% Evolution Modulating Variable--987MA}\\
\hline
Product\# & Model\# & Description & Price\\
\hline
\endhead
213244 & 987MA42060V17 & 987MA42060V17 EVO MOD VS FURNACE & \$2012.46 ea\\\hline
213456 & 987MA42080V17 & 987MA42080V17 EVO MOD VS FURNACE & \$2148.37 ea\\\hline
335981 & 987MA60080V21 & 987MA60080V21 EVO MOD VS FURNACE & \$2193.49 ea\\\hline
392719 & 987MA66100V21 & 987MA66100V21 EVO MOD VS FURNACE & \$2387.93 ea\\\hline
213711 & 987MA66120V24 & 987MA66120V24 EVO MOD VS FURNACE & \$2525.09 ea\\\hline
\end{longtable}
\end{document}
以下是目录可能遇到的潜在情况的示例屏幕截图:
如果您注意到,第一组有 1 张图像,但下一组有另一张跨越多页的图像,下一组也是如此,因此变得非常复杂。