You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX invoice宏包设置金额千位分隔符与英镑前缀方法

LaTeX invoice宏包英镑发票千分位+货币符号调整方案

核心修改思路

直接通过重定义宏包内置的金额格式化逻辑,搭配数字格式化包实现需求,不需要修改宏包源文件:

  • 加载numprint包实现数字千位逗号分隔、固定保留2位小数的格式化效果
  • 重定义invoice内部的金额输出命令,普通费用项仅做千分位格式化,所有合计、总计类金额在数字前添加英镑£符号
  • 修正原代码里的语法错误,保证编译正常

完整可运行代码

\documentclass{letter}
\usepackage{graphicx}
\usepackage{invoice}
% 加载数字格式化工具
\usepackage{numprint}
% 配置数字格式规则:千分位用逗号,小数点用点,强制保留2位小数
\npthousandsep{,}
\npdecimalsign{.}
\nprounddigits{2}

\makeatletter
% 重定义单项费用/报销的金额格式:仅做千分位格式化
\renewcommand*{\FormatFee}[2]{\np{#1 * #2}}
\renewcommand*{\FormatExpense}[2]{\np{#1 * #2}}
% 重定义小计、增值税、总计的金额格式:数字前加£符号+千分位格式化
\renewcommand*{\FormatTotal}[1]{\pounds\np{#1}}
\renewcommand*{\FormatST}[1]{\pounds\np{#1}}
\renewcommand*{\FormatVAT}[1]{\pounds\np{#1}}
\renewcommand*{\FormatGrantTotal}[1]{\pounds\np{#1}}
\makeatother

\date{\today}

\begin{document}
\begin{letter}{Banana}

\opening{\underline{Sent}}

\begin{invoice}{Sterling}{0}
\caption{Baby Limited}
  \ProjectTitle{77}%
  \Fee{Full Quarter; 25 June - 29 September 2022}{625}{20}
\end{invoice}

\end{letter}
\end{document}

效果说明

编译后所有金额数字会自动转为12,500.00格式的千分位显示,所有合计、总计列的金额前会自动带出£符号,最终总计显示为£12,500.00,符合需求。

注:原代码中\underline Sent写法存在语法错误,修改为标准的\underline{Sent}写法,避免编译报错。

内容的提问来源于stack exchange,提问作者Manpreet Pangli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 13:45:31