交易报告高级格式

交易报告高级格式

我正在将内部报告从手动创建的 PDF 文件转换为乳胶文件。而且,在大多数情况下,我可以在页面上获取信息,但格式化比我预期的要困难。我已经能够使用 longtable 包进行基本设置,并使用 colortbl 进行条纹处理。但我还没有弄清楚如何将描边放在页面标题的上方和下方,或者格式化页面顶部的区域。

我附上了目前正在处理的报告示例。任何建议都将不胜感激,尤其是有关格式化包括“中西部”及以上的区域的建议。

http://dl.dropbox.com/u/299036/sample-report.pdf

谢谢。

答案1

以下是一些可能产生所需布局的代码。代码包含一些解释性注释。

标题安全包用于设计页眉和页脚。

、、tabularx和包用于生成表格。除了使用 包,您booktabs还可以使用(如有必要)colortblmultirowtabularx表列包允许表格内的分页符。

\documentclass{article}
\usepackage[landscape,margin=1.5cm,includehead,includefoot]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage[table]{xcolor}
\usepackage{tabularx,booktabs,colortbl,multirow}
\usepackage{lipsum} % just to generate some text

% some space
\newcommand\TSpace{\hspace*{\tabcolsep}}

\setlength\parindent{0pt}

% definition of the page style with required header and footer
\newpagestyle{repstyle}{%
   \renewcommand{\makefootrule}{%
    \color{gray!70}\makebox[0pt][l]{\rule[.9\baselineskip]{\linewidth}{2pt}}}
   \renewcommand{\makeheadrule}{%
    \color{gray!70}\makebox[0pt][l]{\rule[\baselineskip]{\linewidth}{2pt}}%
      \rule[-.5\baselineskip]{\linewidth}{2pt}}
  \sethead
    {\footnotesize\bfseries\TSpace Balance Payments Report -- National}
    {}
    {\footnotesize\bfseries Generated by UserName \today\hspace{2cm}\thepage\TSpace}
  \setfoot{\footnotesize\bfseries\TSpace Reference Code:  SH1SP1SD1DS20110426DE20110426GB3OB1DN1234}{}{}
}

\pagestyle{repstyle}

\newcolumntype{A}{>{\footnotesize}X}
\newcolumntype{B}[1]{>{\footnotesize}p{#1}}
\newcolumntype{C}{>{\footnotesize}c}

% using sans serif font in the document
\renewcommand{\familydefault}{\sfdefault}

\newcommand\Heading[2]{%
\begin{tabularx}{\textwidth}{Xl@{}X}
  \multirow{2}{*}{\huge\bfseries Balance Payments} & #1--#2 
    & Grouped by Region, and ordered by Date / Time \\
  & Restricted to Historical, Pending &
\end{tabularx}\vspace{1ex}
}

% command for writting the first two lines of the payments (Midwest, and Date, Customer Name, etc.). The mandatory argument declares the region: "Midwest", or "East"
\newcommand\RegHeading[1]{%
  \hiderowcolors
  \toprule[1.5pt]\addlinespace[1.5ex]
  \large\bfseries #1 \\ \arrayrulecolor{gray!70}
  \midrule[0.8pt]
  \small\bfseries Date & \small\bfseries Customer Name 
    & \small\bfseries Number &   \small\bfseries Sales Rep Name 
    & \small\bfseries Balance & \small\bfseries Payment Method 
    & \small\bfseries Total \\
  \showrowcolors
}

% command for writting the four last rows (Totals for Midwest, Checking Account, Credit Card and Net Total). Arguments: region, check. acc. total, credit card total, net total.
\newcommand\RegTotal[4]{%
  \hiderowcolors
  \bottomrule[1.5pt]\addlinespace[.3ex]
  Totals for #1 \\
  \midrule
  \multicolumn{2}{l}{\hspace{10pt}\footnotesize Checking Account} &&&&& #2 \\
  \midrule
  \multicolumn{2}{l}{\hspace{10pt}\footnotesize Credit Card} &&&&& #3 \\
  \midrule
  Net Total &&&&&& #4 \\
}


\begin{document}

\Heading{04/26/2011}{04/26/2011}

\rowcolors{1}{blue!10}{}
\arrayrulecolor{black!70}

\begin{tabularx}{\textwidth}{AB{4cm}AB{7cm}AB{3cm}C}
\RegHeading{Midwest}
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Credit Card & 0.50\\
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Checking Account & 0.50\\
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Credit Card & 0.50\\
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Checking Account & 0.50\\
\RegTotal{Midwest}{1.00}{1.00}{2.00}
\end{tabularx}

\rowcolors{1}{blue!10}{}
\begin{tabularx}{\textwidth}{AB{4cm}AB{7cm}AB{3cm}C}
\RegHeading{East}
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Credit Card & 0.50\\
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Checking Account & 0.50\\
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Credit Card & 0.50\\
04/26/2011 & Jones, Mark & 100 & Smith, John & 48.50 & Checking Account & 0.50\\
\RegTotal{East}{1.00}{1.00}{2.00}
\end{tabularx}

\begin{tabularx}{\textwidth}{AB{4cm}AB{7cm}AB{3cm}C}
\toprule[1.5pt]\addlinespace[1.5ex]
\large\bfseries Grand Totals \\\arrayrulecolor{gray!70}
\midrule[0.8pt]
\multicolumn{2}{l}{\hspace{10pt}\footnotesize Checking Account} &&&&& 1.00 \\
\midrule
\multicolumn{2}{l}{\hspace{10pt}\footnotesize Credit Card} &&&&& 1.00 \\
\midrule
Net Total &&&&&& 2.00 \\
\bottomrule
\multicolumn{2}{l}{\scriptsize 8 transactions accounted for.}
\end{tabularx}

\end{document}

在此处输入图片描述

当然,代码可以改进和简化,但它会给你一个很好的起点。

相关内容