我是 Latex 的新手,正在尝试使用它来准备第一份实验室测试报告。我找到了一种方法来模仿现有文档首页的布局,使用一系列堆叠的表格,如下所示。但是,我找不到一种方法来自动调整最后一个(底部)表格的高度以适应其中包含的文本。(即用空行填充表格,这样框架的底部将始终位于同一位置,而不管结论中的文本量有多少。有什么想法吗?或者还有其他方法来制作布局?谢谢。
\documentclass[draft, a4paper, 11pt, english]{report} % Mode draft
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
\usepackage[T1]{fontenc}
\usepackage{tgheros}% Fonts
\usepackage{fancyhdr}% Handling headers and footers
\usepackage[top=3cm, bottom=3cm, left=2cm, right=2 cm]{geometry} %
\usepackage{array}
\usepackage{tabularx}
\usepackage{colortbl,hhline}
\usepackage{xcolor}
\usepackage{ifthen} % Use of tests
\usepackage{lastpage} % Handling last page numbering
\usepackage{lipsum} %only for tests
% [DEFINITION OF GLOBAL CONFIGURATION AND VARIABLES ]-------------------------------------
\def\MaxTableWidth{0.8\textwidth}
\definecolor{Color_logo}{RGB}{0, 115, 174} %setting color for logo
\renewcommand{\familydefault}{\sfdefault}%selecting default font (clone of helvetica) %-------------------------------------------------------------------------
\begin{document}
\thispagestyle{fancy} % enabling special header and footer capability
\fancyhf{} %[cancelling default headers, not suitable for front page]
\renewcommand{\footskip}{1cm} % [distance of footer to bottom]
\setlength{\headheight}{0 pt} %% setting heigth of document header
%--[BEGIN ARGUMENTS FOR FRONT PAGE]---------------
\def\PVnumber {XXXXX} % Setting variable name for document number
\def\CustomerName {Best Customer}
\def\Restricted{Y} %Y
\def\ProductFileNumber {XXXXX}
\def\Date{\today}
\def\Products{Machinery}
\def\PartNumbers{ABCDEF-2, XYZ-2}
\def\TestRequestor{The Requester}
\def\TestPerformer{Test Engineer}
\def\Specification{127-11487 rev 07}
\def\Approver{}
\def\Conclusions{\lipsum[2]}%
%--[END ARGUMENTS FOR FRONT PAGE]---------------
%--------------------------------------------------------------------
%HEADER AND FOOTER FOR PAGE 1 -------------------
\renewcommand{\headrulewidth}{0 pt} % % [thickness header line]
\renewcommand{\headwidth}{\linewidth}% [horizontal length header line]
\renewcommand{\headsep}{0cm} % [distance header-main text]
\renewcommand{\footrulewidth}{1 pt} % [thickness footer line]
\renewcommand{\footskip}{2.5cm}
\lfoot{\footnotesize\textsl{\copyright \ 2011 by MyCompany INC. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording, or by any information storage or retrieval system, without permission in writing from MyCompany INC.}}
% [END OF HEADER AND FOOTER FOR PAGE 1] -------
%----------------------------------------------------------------- -----
%% [PAGE 1 (MADE OF SEVERAL SMALL TABLES)] -------
\large\noindent\flushleft
\begin{tabularx}{\textwidth}{|m{11.5cm}|X|}
\hline\smallskip
\large\centering\textit{\textbf{\textcolor{Color_logo}{BEST TEST LABORATORY}}}&\cellcolor{lightgray}\Large\textbf\ {TEST REPORT}\\
\centering\textbf{NEW YORK}&\cellcolor{lightgray}\ifthenelse{\equal{Y}{\Restricted}}{Restricted to:\\ &\cellcolor{lightgray}\CustomerName}{}\\
\end {tabularx}
\noindent
\begin{tabularx}{\textwidth}{|p{8cm}|p{4.5cm}|X|}
\hline
\textbf{Customer:} \CustomerName&Product file: \ProductFileNumber& \textbf {PV\ \PVnumber}\\ &&Page\ \thepage / \pageref{LastPage}\\
\hline
\end{tabularx}
\begin{tabularx}{\textwidth}{|p{9.5cm}|X|}
\textbf{Product :} \Products&Date: \Date\\
\textbf{Part numbers:} \PartNumbers&Requested by: \TestRequestor\\
&Tests made by: \TestPerformer\\
\textbf{Specification:} \Specification &Visa: \Approver\\
\hline
\end{tabularx}
\begin{tabularx}{\textwidth}{|X|}
\textbf {Scope:} Qualification per specification127-11487\\
\\\\\hline
\textbf {Conclusion:}\\
\Conclusions\\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\hline
\end{tabularx}
\end{document}
答案1
解决方案是将首页的内容放在小页面中所需的高度并将其装箱(在内部表格环境中,因此省略了左右规则以及顶部和底部规则):
\documentclass[draft, a4paper, 11pt, english]{report} % Mode draft
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
\usepackage[T1]{fontenc}
\usepackage{tgheros}% Fonts
\usepackage{fancyhdr}% Handling headers and footers
\usepackage[top=3cm, bottom=3cm, left=2cm, right=2 cm]{geometry} %
\usepackage{array}
\usepackage{tabularx}
\usepackage{colortbl,hhline}
\usepackage{xcolor}
\usepackage{ifthen} % Use of tests
\usepackage{lastpage} % Handling last page numbering
\usepackage{lipsum} %only for tests
% [DEFINITION OF GLOBAL CONFIGURATION AND VARIABLES ]-------------------------------------
\def\MaxTableWidth{0.8\textwidth}
\definecolor{Color_logo}{RGB}{0, 115, 174} %setting color for logo
\renewcommand{\familydefault}{\sfdefault}%selecting default font (clone of helvetica) %-------------------------------------------------------------------------
\begin{document}
\thispagestyle{fancy} % enabling special header and footer capability
\fancyhf{} %[cancelling default headers, not suitable for front page]
\renewcommand{\footskip}{1cm} % [distance of footer to bottom]
\setlength{\headheight}{0 pt} %% setting heigth of document header
%--[BEGIN ARGUMENTS FOR FRONT PAGE]---------------
\def\PVnumber {XXXXX} % Setting variable name for document number
\def\CustomerName {Best Customer}
\def\Restricted{Y} %Y
\def\ProductFileNumber {XXXXX}
\def\Date{\today}
\def\Products{Machinery}
\def\PartNumbers{ABCDEF-2, XYZ-2}
\def\TestRequestor{The Requester}
\def\TestPerformer{Test Engineer}
\def\Specification{127-11487 rev 07}
\def\Approver{}
\def\Conclusions{\lipsum[2]}%
%--[END ARGUMENTS FOR FRONT PAGE]---------------
%--------------------------------------------------------------------
%HEADER AND FOOTER FOR PAGE 1 -------------------
\renewcommand{\headrulewidth}{0 pt} % % [thickness header line]
\renewcommand{\headwidth}{\linewidth}% [horizontal length header line]
\renewcommand{\headsep}{0cm} % [distance header-main text]
\renewcommand{\footrulewidth}{1 pt} % [thickness footer line]
\renewcommand{\footskip}{2.5cm}
\lfoot{\footnotesize\textsl{\copyright \ 2011 by MyCompany INC. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording, or by any information storage or retrieval system, without permission in writing from MyCompany INC.}}
% [END OF HEADER AND FOOTER FOR PAGE 1] -------
%----------------------------------------------------------------- -----
%% [PAGE 1 (MADE OF SEVERAL SMALL TABLES)] -------
\newsavebox{\frontpagebox}
\begin{lrbox}{\frontpagebox}
\begin{minipage}{\textwidth}
\large\flushleft
\begin{tabularx}{\textwidth}{m{11.5cm}|m{\dimexpr\textwidth-11.5cm-4\tabcolsep\relax}}
\smallskip\large\centering\textit{\textbf{\textcolor{Color_logo}{BEST TEST LABORATORY}}}&
\cellcolor{lightgray}\smallskip\Large\textbf\ {TEST REPORT}\\
\centering\textbf{NEW YORK}&
\cellcolor{lightgray}\ifthenelse{\equal{Y}{\Restricted}}{Restricted to:\\ &
\cellcolor{lightgray}\CustomerName}{}\\
\end{tabularx}
\kern-1pt
\begin{tabularx}{\textwidth}{p{8cm}|p{4.5cm}|X}
\hline
\textbf{Customer:} \CustomerName&
Product file: \ProductFileNumber&
\textbf {PV\ \PVnumber}\\ &&
Page\\
hepage / \pageref{LastPage}\\
\hline
\end{tabularx}
\begin{tabularx}{\textwidth}{p{9.5cm}|X}
\textbf{Product :} \Products&Date: \Date\\
\textbf{Part numbers:} \PartNumbers&Requested by: \TestRequestor\\
&Tests made by: \TestPerformer\\
\textbf{Specification:} \Specification &Visa: \Approver\\
\hline
\end{tabularx}
\begin{tabularx}{\textwidth}{X}
\textbf {Scope:} Qualification per specification127-11487\\
\\\\\hline
\textbf {Conclusion:}\\
\Conclusions
\end{tabularx}
\end{minipage}
\end{lrbox}
\noindent{\fboxsep=-\fboxrule\fbox{\parbox[t][0.99\textheight]{\textwidth}{\usebox{\frontpagebox}}}}
\end{document}