我正在使用\usepackage{invoice}
,我想知道我是否可以调整表格的宽度?
\documentclass{article}
\usepackage{invoice}
\date{September 1994}
\begin{document}
\begin{invoice}{USD}{0}
\ProjectTitle{Administrative Fees}
\Fee{Database Management}{1199.99}{3}
\EBC{Tolerating You}{1000.00}
\end{invoice}
\end{document}
答案1
我觉得\my@invoice
环境对第一列的宽度进行了硬编码5cm
,除了重新定义环境之外,我看不出有任何简单的方法可以调整它。
以下代码提供了一个\MyInvoiceWidth
默认值5cm
,可以使用
\renewcommand*{\MyInvoiceWidth}{3cm}%
如下表第二张表的情况一样。
笔记:
- 您可以
longtable
根据需要更改规格。
代码:
\documentclass{article}
\usepackage{invoice}
\date{September 1994}
\newcommand*{\MyInvoiceWidth}{5cm}%
\makeatletter
\renewenvironment{\my@invoice}[2]{%
\setcounter{Fee@ctr}{0}% % reset counter
\setcounter{Expense@ctr}{0}% % reset counter
\def\Null{0}%
\setcounter{Project}{0}%
\ST@Reset\Total@Reset%
\def\BC{#1}%
\def\VAT@rate{#2}%
\ifx\VAT@rate\Null\VATnonzerofalse\else\VATnonzerotrue\fi%
\ifVATnonzero
\message{^^J^^JVAT is not zero!^^J^^J}%
\else
\message{^^J^^JVAT is zero!^^J^^J}%
\fi%
% The VAT is: \the\VAT@rate % Debugging Diagnostics only
\parindent=0cm%
\ifcase\Flag % 0: Invoice not started yet
%
\gdef\Flag{1}%
%\begin{center}% Removed 20050621 by suggestion from ...
\begin{longtable}{p{\MyInvoiceWidth}lrrr}%
%
\else \error@message{\NoInvoiceNesting}%
\fi}%
% At the end of environment:
% Yields state 8->0, Close and complete invoice, finish tables, etc.
{%
\ifcase\Flag % 0: Invoice not started yet
%
\error@message{\MissingOpening}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 1: Start invoice
%
\error@message{\MissingProject}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 2: Start project, print title
%
\error@message{\MissingInputData}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 3: Print remuneration item
%
\ifnum\theProject>0 \ST@Fee\ST@Project\fi%
\Tot@l%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 4: Print subtotal remuneration
%
\ifnum\theProject>1 \ST@Project\fi%
\Tot@l%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 5: Expense item
%
\ifnum\theProject>1 \ST@Expenses\ST@Project\fi%
\Tot@l%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 6: Print subtotal expenses
%
\ifnum\theProject>1 \ST@Project\fi%
\Tot@l%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 7: Print subtotal project
%
\Tot@l%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\or % 8: Print total, close invoice
%
\warning@message{\InvoiceCompleted}%
%
\else \error@message{\InternalError}%
\fi%
\gdef\Flag{0}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatother
\begin{document}
\noindent
\begin{invoice}{USD}{0}
\ProjectTitle{Administrative Fees}
\Fee{Database Management}{1199.99}{3}
\EBC{Tolerating You}{1000.00}
\end{invoice}
\renewcommand*{\MyInvoiceWidth}{3cm}%
\noindent
\begin{invoice}{USD}{0}
\ProjectTitle{Administrative Fees}
\Fee{Database Management}{1199.99}{3}
\EBC{Tolerating You}{1000.00}
\end{invoice}
\end{document}
答案2
通过一些基本的宏来创建自己的“发票”并不困难。以下是一次尝试:
\documentclass{article}
\usepackage{pgfplots}
\pgfkeys{/pgf/number format/.cd,std,fixed zerofill,precision=2,/pgf/fpu = true}
\usepackage{tabularx, booktabs}
\newcommand{\invoicetitle}{Administrative Fees}
\newcommand{\invoicetitleformat}{\bfseries\large}
\newlength{\titleskip}\setlength{\titleskip}{\baselineskip}
\newcommand{\invoicecurrency}{USD}
\makeatletter
\newcounter{activity@num}
\newcommand{\activityitemtotal@}{0}
\newcommand{\activity}[3]{%
\\
\ifnum\value{activity@num}=0 \midrule\fi%
\stepcounter{activity@num}%
\pgfmathparse{#2 * #3}\global\let\activityitem@\pgfmathresult%
\pgfmathparse{\activityitemtotal@ + \activityitem@}\global\let\activityitemtotal@\pgfmathresult%
#1 & & \pgfmathprintnumber{#2} & #3 & \pgfmathprintnumber{\activityitem@}%
}
\newcounter{expense@num}
\newcommand{\expenseitemtotal@}{0}
\newcommand{\expense}[4][\invoicecurrency]{%
\\
\ifnum\value{expense@num}=0 \midrule\fi%
\stepcounter{expense@num}%
\pgfmathparse{#3 * #4}\global\let\expenseitem@\pgfmathresult%
\pgfmathparse{\expenseitemtotal@ + \expenseitem@}\global\let\expenseitemtotal@\pgfmathresult%
#2 & #1 & \pgfmathprintnumber{#3} & #4 & \pgfmathprintnumber{\expenseitem@}%
}
\newcommand{\activitytotal}{%
Sum fees & & & & \pgfmathprintnumber{\activityitemtotal@}}
\newcommand{\expensetotal}{%
Sum expenses & & & & \pgfmathprintnumber{\expenseitemtotal@}}
\newcommand{\totaltotal}{%
\textbf{Total} & & & & %
\pgfmathparse{\activityitemtotal@ + \expenseitemtotal@}%
\pgfmathprintnumber{\pgfmathresult}%
}
\begin{document}
\begin{center}
{\invoicetitleformat\invoicetitle\par}\nobreak
\vspace*{\titleskip}
\begin{tabularx}{\linewidth}{Xlrrr}
\toprule
\textbf{Activity} & & Rate/Unit & Count & Amount (\invoicecurrency)
\activity{Database management}{1199.99}{3}
\activity{Office management}{123.45}{2}
\activity{Product delivery}{6789.10}{2}
\\[.5\normalbaselineskip]
\textbf{Expense} & Currency & Amount & Factor & \invoicecurrency
\expense{Tolerating you}{1000.00}{1}
\expense[CDN]{Office supplies}{12.00}{1.29}
\\[.5\normalbaselineskip]
\midrule
\activitytotal \\
\expensetotal \\
\bottomrule
\totaltotal \\
\bottomrule
\end{tabularx}
\end{center}
\end{document}
您会注意到,发票的构造是使用tabularx
宽度设置为\linewidth
。您可以将其调整为(例如).6\linewidth
仅占用一行宽度的 60%。此外,现在您可以自由调整列规格以满足您的需求。
当然,这取决于你对invoice
,但可以根据需要添加功能。至少,我认为它比更灵活invoice
。