添加文本和变量

添加文本和变量

我不知道任何 LaTeX 代码,但我不知道为什么它如此难以编辑...:( 我不断收到此错误:“未定义的控制序列”。

这是压缩文件:https://www.dropbox.com/s/oqs85dacw8yl3ul/latex-rechnung.rar?dl=0

这是我的代码:

\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 {ifthen}

\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
\newcommand{\invoiceReference}{2019\_01\_01\_1} % Rechnungsnummer (z.B. 20150122-4) YYYYMMDD-1
\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 ##################


% ##################Job DATA ####################
\def \performaceStart {01.01.2019}
\def \performaceEnd {02.01.2019}
% ##################Job DATA ####################


% ################## Customer DATA ##################
\newcommand{\customerCompany}{Firma ABC} %ggf. Firma
\newcommand{\customerName}{Max Mustermann} % Name
\newcommand{\customerStreet}{Musterstraße 10} % Straße
\newcommand{\customerZIP}{12345} % Postleitzahl
\newcommand{\customerCity}{Musterort} % Ort
\newcommand{\customerNumber}{1000} % 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{Rechnungsnummer: }% <========================================
\def \customernr{Kundennummer: }%
\def \performanceDuration{Leistungszeitraum: }

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


\setkomavar{firsthead}{\hfill
   \parbox[t][\headheight][t]{7.3cm}{% 
   \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}


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

\ProjectTitle{Tagesleistungen} % 
\FeeDay{Freelance Arbeit}   {10}        {1}

\ProjectTitle{Projekttitel} % 
\Fee{Überstunden}           {20}    {1}



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

% Rabatt
\Discount{Rabatt} {0} % 
            \end{invoice}
    \ps Bitte zahlen Sie den Gesamtbetrag unter Angabe der Rechnungsnummer auf das aufgeführte Konto.
    \ps Kleinunternehmerregelung:\\
    Im ausgewiesenen Betrag ist gemäß § 19 UStG keine Umsatzsteuer 
    enthalten.

        \closing{\invoiceClosing}
        \invoiceEnclosures



    \end{letter}
\end{document}  

我想在“Leistungszeitraum:”下方添加两个可以自行设置的日期。因此有两个变量\performanceStart\performanceEnd可设置,然后将它们粘贴到红色矩形所在的位置,中间有一个“-”或单词。

我现在拥有的

非常令人沮丧的 LaTeX......

答案1

好了,您已经定义了两个命令\performaceStart\performaceEnd

然后您可以简单地将它们添加到如下定义中location

\setkomavar{location}{%
      \\[\baselineskip] \\[\baselineskip]
      \flushright\small \invoicenr \invoiceReference\\[5pt]
      \customernr\\
      \customerNumber\\[5pt]
      \performanceDuration\\ 
      \performaceStart{} -- \performaceEnd % <====================================
    }

完整代码

\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
\newcommand{\invoiceReference}{2019\_01\_01\_1} % Rechnungsnummer (z.B. 20150122-4) YYYYMMDD-1
\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 ##################


% ##################Job DATA ####################
\def \performaceStart {01.01.2019}
\def \performaceEnd {02.01.2019}
% ##################Job DATA ####################


% ################## Customer DATA ##################
\newcommand{\customerCompany}{Firma ABC} %ggf. Firma
\newcommand{\customerName}{Max Mustermann} % Name
\newcommand{\customerStreet}{Musterstraße 10} % Straße
\newcommand{\customerZIP}{12345} % Postleitzahl
\newcommand{\customerCity}{Musterort} % Ort
\newcommand{\customerNumber}{1000} % 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{Rechnungsnummer: }% <========================================
\def \customernr{Kundennummer: }%
\def \performanceDuration{Leistungszeitraum: }

\setkomavar{location}{%
      \\[\baselineskip] \\[\baselineskip]
      \flushright\small \invoicenr \invoiceReference\\[5pt]
      \customernr\\
      \customerNumber\\[5pt]
      \performanceDuration\\ 
      \performaceStart{} -- \performaceEnd % <============================
    }


\setkomavar{firsthead}{\hfill
   \parbox[t][\headheight][t]{7.3cm}{% 
   \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}


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

\ProjectTitle{Tagesleistungen} % 
\FeeDay{Freelance Arbeit}   {10}        {1}

\ProjectTitle{Projekttitel} % 
\Fee{Überstunden}           {20}    {1}



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

% Rabatt
\Discount{Rabatt} {0} % 
            \end{invoice}
    \ps Bitte zahlen Sie den Gesamtbetrag unter Angabe der Rechnungsnummer auf das aufgeführte Konto.
    \ps Kleinunternehmerregelung:\\
    Im ausgewiesenen Betrag ist gemäß § 19 UStG keine Umsatzsteuer 
    enthalten.

        \closing{\invoiceClosing}
        \invoiceEnclosures



    \end{letter}
\end{document} 

及其结果:

生成的 pdf

顺便说一句:您不需要ifthen这里的包,请删除它(如果需要,您应该在之前加载它hyperref)。

相关内容