更改环境的字体

更改环境的字体

我正在使用在线找到的 .sty 文件自动计算我的 KOMA 发票模板中的金额。我已使用以下方法将信件的字体更改为 helvetica

\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
\usepackage[T1]{fontenc}

但是,发票中使用的数字和包生成的数字仍采用 LaTeX 的默认字体。我如何更改包,以便它也适用于所有文本元素?附加问题:如何在重新设置环境\noindent` 不起作用helvet后立即消除缩进。?

包 rechnung.sty(invoice.sty):

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rechnung}

\RequirePackage{fp}
\RequirePackage{calc}
\RequirePackage{array}
\RequirePackage{booktabs}

% Commas instead of dot in mathmode
\mathchardef\period=\mathcode`.
\DeclareMathSymbol{.}{\mathord}{letters}{"3B}

\newcounter{invoice@cost}
\newcounter{invoice@vat}

\newcommand*{\format@float}[1]{\FPround{\invoice@t}{#1}{2}$\invoice@t$}
\newcommand*{\format@int}[1]{$#1$}
\newcommand*{\total}[1]{\FPdiv{\invoice@t}{\arabic{#1}}{1000}\format@float{\invoice@t}}
\newcommand*\textPosten{\bfseries Posten}
\newcommand*\textPreis{St\"uckpreis}
\newcommand*\textAnzahl{Anzahl}
\newcommand*\textBetrag{Betrag}

\newenvironment*{invoice}[1]{
  \setcounter{invoice@cost}{0}
  \setcounter{invoice@vat}{0}
  \def\invoice@VATval{#1}%
  % 
  \newcommand*{\Fee}[3]{%
    \addtocounter{invoice@cost}{1000 * \real{##2} * \real{##3}}%
    \addtocounter{invoice@vat}{10 * \real{#1} * \real{##2} * \real{##3}}%
    {##1} & \format@float{##2} & \format@int{##3} & \FPmul{\invoice@cost}{##2}{##3}\format@float{\invoice@cost} \cr%
  }%
  % 
  ~\par\noindent
  \begin{tabular}{p{\dimexpr0.49\linewidth-2\tabcolsep}*{3}{>{\hfill}p{\dimexpr0.17\linewidth-2\tabcolsep}}}%
    \toprule%
    {\textPosten} & {\textPreis} & {\textAnzahl} & {\textBetrag} \cr%
    \midrule%
  }{%
    \if\invoice@VATval0\else%
    \midrule%
    {Zwischensumme} & & & {\total{invoice@cost}} \cr%
    {MWSt. (\invoice@VATval\,\%)} & & & {\total{invoice@vat}} \cr%
    \fi%
    \midrule%
    \setcounter{invoice@cost}{\theinvoice@cost + \theinvoice@vat}%
    {\bfseries Summe} & & & {\boldmath \total{invoice@cost}} \cr%
    \bottomrule%
  \end{tabular}%
  \par~%
}

我的发票的 MWE:

\documentclass[
    fontsize=12pt,    
    parskip=full,
    paper=A4,
    fromalign=right,
    fromphone=true,
    fromfax=false,
    fromemail=true,
    fromurl=false,
    foldmarks=true,
    version=last
]{scrlttr2}
% \KOMAoptions{enlargefirstpage=true}

\usepackage{rechnung}

\setlength{\parindent}{0pt}

\renewcommand*{\raggedsignature}{\raggedright}

\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault} 
\usepackage[T1]{fontenc}

\usepackage[utf8]{inputenc}

\usepackage{eurosym}
\DeclareUnicodeCharacter{20AC}{\euro}

\usepackage[ngerman]{babel}

\usepackage[hidelinks]{hyperref}

\begin{document}

\setkomavar{fromname}{John Doe}
\setkomavar{fromaddress}{LaTeX Street}
\setkomavar{date}{\today}
\setkomavar{subject}{Invoice0001}

% Empfänger
\begin{letter}{
    Your Company Ltd.\\
    Companyst. 4
}

\opening{Hi,}

\begin{invoice}{0}
    \Fee{All the things}{987654321}{1}
\end{invoice}
Please don't be indented :(

\closing{KR}

\end{letter}

\end{document}

答案1

将这些添加到您的.tex文件中\usepackage{rechnung}

\makeatletter
\renewcommand*{\format@float}[1]{\FPround{\invoice@t}{#1}{2}\invoice@t}
\renewcommand*{\format@int}[1]{#1}
\makeatother

文件的完整内容如下.tex

\documentclass[
fontsize=12pt,
parskip=full,
paper=A4,
fromalign=right,
fromphone=true,
fromfax=false,
fromemail=true,
fromurl=false,
foldmarks=true,
version=last
]{scrlttr2}
\usepackage{rechnung}
\makeatletter
\renewcommand*{\format@float}[1]{\FPround{\invoice@t}{#1}{2}\invoice@t}
\renewcommand*{\format@int}[1]{#1}
\makeatother
\setlength{\parindent}{0pt}
\renewcommand*{\raggedsignature}{\raggedright}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{eurosym}
\DeclareUnicodeCharacter{20AC}{\euro}
\usepackage[ngerman]{babel}
\usepackage[hidelinks]{hyperref}
\begin{document}
\setkomavar{fromname}{John Doe}
\setkomavar{fromaddress}{LaTeX Street}
\setkomavar{date}{\today}
\setkomavar{subject}{Invoice0001}
\begin{letter}{
Your Company Ltd.\\
Companyst. 4
}
\opening{Hi,}
\begin{invoice}{0}
\Fee{All the things}{987654.321}{1}
\end{invoice}
Please don't be indented :(
\closing{KR}
\end{letter}
\end{document}

在此处输入图片描述

相关内容