添加特定文本和变量

添加特定文本和变量

我想添加此文本Kundennummer: {customer specific number that I change manually}

完美就在下面: \newcommand{\invoiceReference}{2019\textunderscore01\textunderscore14\textunderscore1} % Rechnungsnummer (z.B. 20150122-4)

这样顾客号码就出现在红色矩形框中:

删除了我的名字和其他内容

\documentclass[a4paper]{scrlttr2}

\usepackage[top=2cm, bottom=1cm, left=2cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{color}
\usepackage[hidelinks]{hyperref}

\usepackage[german]{invoice}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\def\UnitDay            {Preis/Tag}% <========================================

\newcommand{\FeeDay@Title}{% <==========================================
    \\
    \noindent\textbf{\Activity}&&\UnitDay&\Count&\Amount\ (\BC)\\
    \hline%
}%

\newcommand{\FeeDay}[3]{% Yields state 3, Print Fee Item <==============
    %
    % #1 Contents
    % #2 Fee per Day
    % #3 Unit Count
    %
    \ifcase\Flag % 0: Invoice not started yet
        \error@message{\MissingOpening}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 1: Start invoice
        %
        \error@message{\MissingProject}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 2: Start project, print title
        %
        \FeeDay@Title%
        \Fee@Line{#1}{#2}{#3}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 3: Print remuneration item
        %
        \Fee@Line{#1}{#2}{#3}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 4: Print subtotal remuneration
        %
        \warning@message{\FeeSTExists}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 5: Expense item
        %
        \error@message{\FeeBeforeExpense}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 6: Print subtotal expenses
        %
        \error@message{\FeeBeforeExpense}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 7: Print subtotal project
        %
        \error@message{\ProjectCompletedNoFee}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 8: Print total, close invoice
        %
        \error@message{\InvoiceCompletedNoFee}%
        %
        %
    \else \error@message{\InternalError}%
    \fi%
}%
\makeatother


\renewcommand{\familydefault}{\sfdefault}

% include meta data
\include{_data} % <============== delete in this file the following data!
% ################## invoice DATA ##################
\newcommand{\invoiceDate}{\today} % Datum der rechnungsstellung, change `\today' to a different  date, if you do not    want to use todays date
\newcommand{\payDate}{DD.MM.YYYY} % Datum der Zahlungsfrist
\newcommand{\invoiceReference}{2019\textunderscore01\textunderscore14\textunderscore1} % Rechnungsnummer (z.B.  20150122-4)
\newcommand{\invoiceSalutation}{Sehr geehrte Damen und Herren,} % die Anrede
\newcommand{\invoiceText}{folgende Positionen werden in Rechnung gestellt:} % Rechnungstext
\newcommand{\invoiceEnclosures}{} % \encl{} einfügen
\newcommand{\invoiceClosing}{Mit freundlichen Grüßen}
% ################## invoice DATA ##################

% ################## Customer DATA ##################
\newcommand{\customerCompany}{Firma XYZ} %ggf. Firma
\newcommand{\customerName}{Max Mustermann} % Name
\newcommand{\customerStreet}{Robert-Koch-Str. 12} % Straße
\newcommand{\customerZIP}{12345} % Postleitzahl
\newcommand{\customerCity}{Musterstadt} % Ort
% ################## Customer DATA ##################

\setkomavar{fromname}{\senderName}
\setkomavar{fromaddress}{\senderStreet \\ \senderZIP \ \senderCity}
\setkomavar{place}{\senderCity}
\setkomavar{date}{\invoiceDate}
\setkomavar{fromphone}{\senderTelephone}
\setkomavar{frommobilephone}{\senderMobilephone}
\setkomavar{fromemail}{\href{mailto:\senderEmail}{\nolinkurl{\senderEmail}}}
\setkomavar{subject}{Rechnung}
\setkomavar{location}{
  \\[\baselineskip] \\[\baselineskip]
  \flushright \small {\vspace{1cm}Rechnungsnummer: 
  \invoiceReference}
}

\setkomavar{firsthead}{\hfill
   \parbox[t][\headheight][t]{7.2cm}{
   \footnotesize
   \raggedright
   \flushright
   \color[gray]{.3}%
    \begin{tabular}{rl}
         Anschrift & \usekomavar{fromname}\\
         & \senderStreet\\
         & \senderZIP  \ \senderCity \\
         \\
         %\Telefon \ Telefon:  \` \senderTelephone \\ %<===================  remove the `%' and go into `_data.tex' and     add an phone number
         Mobil  & \usekomavar{frommobilephone} \\
         E-Mail  & \usekomavar{fromemail} \\
         %Webseite & {\normalfont\ttfamily  \senderWeb } \\ %<===================  remove the `%' and go into   `_data.tex' and add an URL
         \\
         Steuernummer & \taxID \\
         \\
         Institut & \accountBankName \\
         IBAN & \accountIBAN \\
         BIC & \accountBIC
    \end{tabular}                   
   }%
}


\begin{document}
    \begin{letter}{\customerCompany \\ \customerName \\ 
    \customerStreet \\ \customerZIP \ \customerCity}

            \opening{\invoiceSalutation}
            \invoiceText
            \begin{invoice}{Euro}{0}

\ProjectTitle{Tagesleistungen} % <====================================== Tagesleistungen
\FeeDay{Freelance Arbeit}{300.00}{15}

\ProjectTitle{Projekttitel} % <========================================= Stundenleistungen
\Fee{Überstunden}{30.00}{2}




%Auslagen % <=================================================Auslagen
%\EBC{Hotel, 12 Nächte} {2400.00} % \EBCi{Hotel, 12 Nächte} {2400.00}
%\STExpenses

% Rabatt
\Discount{Rabatt} {0} % <========================================== Rabatt
            \end{invoice}
    \ps Bitte überweisen Sie den Rechnungsbetrag auf das unten aufgeführte Konto. 
    \ps Kleinunternehmerregelung: Im ausgewiesenen Betrag ist gemäß § 19 UStG keine Umsatzsteuer enthalten.

        \closing{\invoiceClosing}
        \invoiceEnclosures



    \end{letter}
\end{document}  

答案1

这里的技巧是将命令的内容更改\location

\setkomavar{location}{%
  \\[\baselineskip] \\[\baselineskip]
  \flushright\small Rechnungsnummer: \invoiceReference\\[1pt]
  Kundennummer: \customerNumber
}

我添加了一行Kundennummer: \customerNumber,这意味着您必须\customerNumber向客户的数据添加新命令。最好使用每次开具新发票时都写入的命令。这样可以减少错误。

但现在你必须像这样定义这个命令:

 \newcommand{\customerNumber}{1234567} % Kundennummer

最好的解决方案是定义两个新命令,例如

 \def\invoicenr{Rechnungsnummer:}%
 \def\customernr{Kundennummer:}%

使您的发票更加独立于语言(当然,您也需要为其他语言定义这些词)。然后您可以使用

\setkomavar{location}{%
  \\[\baselineskip] \\[\baselineskip]
  \flushright\small \invoicenr \invoiceReference\\[1pt]
  \customernr \customerNumber
}

为了避免 Rechnungsnummer: 和当前号码的分裂,您可以使用较短的名称,例如

 \def\invoicenr{Rechnungsnr.:}%
 \def\customernr{Kundennr.:}%

使用完整的代码(基于您最后一个问题以及上面描述的更改)

\documentclass[a4paper]{scrlttr2}

\usepackage[top=2cm, bottom=1cm, left=2cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{color}
\usepackage[hidelinks]{hyperref}

\usepackage[german]{invoice}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\def\UnitDay            {Preis/Tag}% <========================================

\newcommand{\FeeDay@Title}{% <==========================================
    \\
    \noindent\textbf{\Activity}&&\UnitDay&\Count&\Amount\ (\BC)\\
    \hline%
}%

\newcommand{\FeeDay}[3]{% Yields state 3, Print Fee Item <==============
    %
    % #1 Contents
    % #2 Fee per Day
    % #3 Unit Count
    %
    \ifcase\Flag % 0: Invoice not started yet
        \error@message{\MissingOpening}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 1: Start invoice
        %
        \error@message{\MissingProject}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 2: Start project, print title
        %
        \FeeDay@Title%
        \Fee@Line{#1}{#2}{#3}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 3: Print remuneration item
        %
        \Fee@Line{#1}{#2}{#3}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 4: Print subtotal remuneration
        %
        \warning@message{\FeeSTExists}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 5: Expense item
        %
        \error@message{\FeeBeforeExpense}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 6: Print subtotal expenses
        %
        \error@message{\FeeBeforeExpense}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 7: Print subtotal project
        %
        \error@message{\ProjectCompletedNoFee}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 8: Print total, close invoice
        %
        \error@message{\InvoiceCompletedNoFee}%
        %
        %
    \else \error@message{\InternalError}%
    \fi%
}%
\makeatother


\renewcommand{\familydefault}{\sfdefault}

% include meta data
\include{_data} % <============== delete in this file the following data!
% ################## invoice DATA ##################
\newcommand{\invoiceDate}{DD.MM.YYYY} % Datum der rechnungsstellung
\newcommand{\payDate}{DD.MM.YYYY} % Datum der Zahlungsfrist
\newcommand{\invoiceReference}{20150122-4} % Rechnungsnummer (z.B. 20150122-4) YYYYMMDD-1
\newcommand{\invoiceSalutation}{Sehr geehrte Damen und Herren,} % die Anrede
\newcommand{\invoiceText}{Für die von mir erbrachte Leistung erhalten sie
hiermit die Rechnung. Bitte zahlen Sie den unten aufgeführten Gesamtbetrag
unter Angabe der Rechnungsnummer (\invoiceReference) bis
zum \payDate \ auf das angegebene Konto ein.} % Rechnungstext
\newcommand{\invoiceEnclosures}{} % \encl{} einfügen
\newcommand{\invoiceClosing}{Mit freundlichen Grüßen}
% ################## invoice DATA ##################

% ################## Customer DATA ##################
\newcommand{\customerCompany}{Firma XYZ} %ggf. Firma
\newcommand{\customerName}{Max Mustermann} % Name
\newcommand{\customerStreet}{Robert-Koch-Str. 12} % Straße
\newcommand{\customerZIP}{12345} % Postleitzahl
\newcommand{\customerCity}{Musterstadt} % Ort
\newcommand{\customerNumber}{1234567} % Kundennummer <==================
% ################## Customer DATA ##################

\setkomavar{fromname}{\senderName}
\setkomavar{fromaddress}{\senderStreet \\ \senderZIP \ \senderCity}
\setkomavar{place}{\senderCity}
\setkomavar{date}{\invoiceDate}
\setkomavar{fromphone}{\senderTelephone}
\setkomavar{frommobilephone}{\senderMobilephone}
\setkomavar{fromemail}{\href{mailto:\senderEmail}{\nolinkurl{\senderEmail}}}
\setkomavar{subject}{Rechnung}

\def\invoicenr{Rechnungsnr.:}% <========================================
\def\customernr{Kundennr.:}%

\setkomavar{location}{%
      \\[\baselineskip] \\[\baselineskip]
      \flushright\small \invoicenr \invoiceReference\\[1pt] % <=========
      \customernr \customerNumber
    }


\setkomavar{firsthead}{\hfill
   \parbox[t][\headheight][t]{7cm}{% 
   \footnotesize
   \raggedright
   \flushright
   \color[gray]{.3}%
    \begin{tabular}{rl}
         Anschrift & \usekomavar{fromname}\\
         & \senderStreet\\
         & \senderZIP  \ \senderCity \\
         \\
         %\Telefon \ Telefon:  \` \senderTelephone \\
         Mobil  & \usekomavar{frommobilephone} \\
         E-Mail  & \usekomavar{fromemail} \\
         Webseite & {\normalfont\ttfamily  \senderWeb } \\
         \\
         Steuernummer & \taxID \\
         \\
         Institut & \accountBankName \\
         IBAN & \accountIBAN \\
         BIC & \accountBIC
    \end{tabular}                   
   }%
}


\begin{document}
    \begin{letter}{\customerCompany \\ \customerName \\ 
    \customerStreet \\ \customerZIP \ \customerCity}

            \includegraphics[width=0.15\textwidth]{logo.png}            
            \opening{\invoiceSalutation}
            \invoiceText
            \begin{invoice}{Euro}{0}
\ProjectTitle{Projekttitel} % 
\Fee{Musterdienstleistung 1}{30.00}{4}
\Fee{Musterdienstleistung 2}{36.00}{7}
\ProjectTitle{Tagesleistungen} % 
\FeeDay{Musterdienstleistung 3}{360.00}{3}

% Auslagen
%\EBC{Hotel, 12 Nächte} {2400.00} % \EBCi{Hotel, 12 Nächte} {2400.00}
%\STExpenses

% Rabatt
\Discount{Rabatt} {20} % 
            \end{invoice}
        \ps Im ausgewiesenen Betrag ist gemäß § 19 UStG keine Umsatzsteuer 
        enthalten.

        \closing{\invoiceClosing}
        \invoiceEnclosures



    \end{letter}
\end{document}

得到结果:

在此处输入图片描述

如果您希望客户编号和记录编号以及相关数字一个在另一个之下,只需更改\location

\setkomavar{location}{%
      \\[\baselineskip] \\[\baselineskip]
      \flushright\small \invoicenr\\[1pt] \invoiceReference\\[1pt] % <=========
      \customernr\\[1pt] \customerNumber
    }

结果如下:

在此处输入图片描述

请参阅您可以使用

\newcommand{\invoiceReference}{2019\_01\_14\_01}

生成发票参考号2019_01_14_01,但我不建议这样做。最好使用2019-01-14-01...

答案2

您只需使用tabular两行环境作为参考:

\documentclass[a4paper]{scrlttr2}

\usepackage[top=2cm, bottom=1cm, left=2cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{color}
\usepackage[hidelinks]{hyperref}

\usepackage[german]{invoice}

\newcommand\senderName{Foo Bar}
\newcommand\senderStreet{Foo Street}
\newcommand\senderZIP{12345}
\newcommand\senderCity{Bar City}
\newcommand\senderMobilephone{0123 3456789}
\newcommand\senderEmail{[email protected]}
\newcommand\taxID{4654TE132E}
\newcommand\accountBankName{MyBank}
\newcommand\accountIBAN{DE12 3456 7890 1234 5678 90}
\newcommand\accountBIC{ABCDEFG0HIJ}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\def\UnitDay            {Preis/Tag}% <========================================

\newcommand{\FeeDay@Title}{% <==========================================
    \\
    \noindent\textbf{\Activity}&&\UnitDay&\Count&\Amount\ (\BC)\\
    \hline%
}%

\newcommand{\FeeDay}[3]{% Yields state 3, Print Fee Item <==============
    %
    % #1 Contents
    % #2 Fee per Day
    % #3 Unit Count
    %
    \ifcase\Flag % 0: Invoice not started yet
        \error@message{\MissingOpening}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 1: Start invoice
        %
        \error@message{\MissingProject}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 2: Start project, print title
        %
        \FeeDay@Title%
        \Fee@Line{#1}{#2}{#3}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 3: Print remuneration item
        %
        \Fee@Line{#1}{#2}{#3}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 4: Print subtotal remuneration
        %
        \warning@message{\FeeSTExists}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 5: Expense item
        %
        \error@message{\FeeBeforeExpense}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 6: Print subtotal expenses
        %
        \error@message{\FeeBeforeExpense}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 7: Print subtotal project
        %
        \error@message{\ProjectCompletedNoFee}%
        %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \or % 8: Print total, close invoice
        %
        \error@message{\InvoiceCompletedNoFee}%
        %
        %
    \else \error@message{\InternalError}%
    \fi%
}%
\makeatother


\renewcommand{\familydefault}{\sfdefault}

% include meta data
\include{_data} % <============== delete in this file the following data!
% ################## invoice DATA ##################
\newcommand{\invoiceDate}{\today} % Datum der rechnungsstellung, change `\today' to a different  date, if you do not    want to use todays date
\newcommand{\payDate}{DD.MM.YYYY} % Datum der Zahlungsfrist
\newcommand{\invoiceReference}
  {%
    \begin{tabular}[]{@{}r@{}}
      2019\textunderscore01\textunderscore14\textunderscore1\\
      MyCustomer123%
    \end{tabular}%
  } % Rechnungsnummer (z.B.  20150122-4)
\newcommand{\invoiceSalutation}{Sehr geehrte Damen und Herren,} % die Anrede
\newcommand{\invoiceText}{folgende Positionen werden in Rechnung gestellt:} % Rechnungstext
\newcommand{\invoiceEnclosures}{} % \encl{} einfügen
\newcommand{\invoiceClosing}{Mit freundlichen Grüßen}
% ################## invoice DATA ##################

% ################## Customer DATA ##################
\newcommand{\customerCompany}{Firma XYZ} %ggf. Firma
\newcommand{\customerName}{Max Mustermann} % Name
\newcommand{\customerStreet}{Robert-Koch-Str. 12} % Straße
\newcommand{\customerZIP}{12345} % Postleitzahl
\newcommand{\customerCity}{Musterstadt} % Ort
% ################## Customer DATA ##################

\setkomavar{fromname}{\senderName}
\setkomavar{fromaddress}{\senderStreet \\ \senderZIP \ \senderCity}
\setkomavar{place}{\senderCity}
\setkomavar{date}{\invoiceDate}
\setkomavar{fromphone}{\senderTelephone}
\setkomavar{frommobilephone}{\senderMobilephone}
\setkomavar{fromemail}{\href{mailto:\senderEmail}{\nolinkurl{\senderEmail}}}
\setkomavar{subject}{Rechnung}
\setkomavar{location}{
  \\[\baselineskip] \\[\baselineskip]
  \flushright \small {\vspace{1cm}Rechnungsnummer: 
  \invoiceReference}
}

\setkomavar{firsthead}{\hfill
   \parbox[t][\headheight][t]{7.2cm}{
   \footnotesize
   \raggedright
   \flushright
   \color[gray]{.3}%
    \begin{tabular}{rl}
         Anschrift & \usekomavar{fromname}\\
         & \senderStreet\\
         & \senderZIP  \ \senderCity \\
         \\
         %\Telefon \ Telefon:  \` \senderTelephone \\ %<===================  remove the `%' and go into `_data.tex' and     add an phone number
         Mobil  & \usekomavar{frommobilephone} \\
         E-Mail  & \usekomavar{fromemail} \\
         %Webseite & {\normalfont\ttfamily  \senderWeb } \\ %<===================  remove the `%' and go into   `_data.tex' and add an URL
         \\
         Steuernummer & \taxID \\
         \\
         Institut & \accountBankName \\
         IBAN & \accountIBAN \\
         BIC & \accountBIC
    \end{tabular}                   
   }%
}


\begin{document}
    \begin{letter}{\customerCompany \\ \customerName \\ 
    \customerStreet \\ \customerZIP \ \customerCity}

            \opening{\invoiceSalutation}
            \invoiceText
            \begin{invoice}{Euro}{0}

\ProjectTitle{Tagesleistungen} % <====================================== Tagesleistungen
\FeeDay{Freelance Arbeit}{300.00}{15}

\ProjectTitle{Projekttitel} % <========================================= Stundenleistungen
\Fee{Überstunden}{30.00}{2}




%Auslagen % <=================================================Auslagen
%\EBC{Hotel, 12 Nächte} {2400.00} % \EBCi{Hotel, 12 Nächte} {2400.00}
%\STExpenses

% Rabatt
\Discount{Rabatt} {0} % <========================================== Rabatt
            \end{invoice}
    \ps Bitte überweisen Sie den Rechnungsbetrag auf das unten aufgeführte Konto. 
    \ps Kleinunternehmerregelung: Im ausgewiesenen Betrag ist gemäß § 19 UStG keine Umsatzsteuer enthalten.

        \closing{\invoiceClosing}
        \invoiceEnclosures



    \end{letter}
\end{document}  

在此处输入图片描述

相关内容