Sie sind hier

Beispiel für Infoblock statt Geschäftszeile

AnhangGröße
PDF icon infoblock.pdf36.9 KB
Die folgende lco-Datei zeigt, wie man durch Erweiterung und Umdefinierung interner Makros die Geschäftszeile durch einen Infoblock ersetzen kann. Dieser Infoblock wird automatisch in die Absenderergänzung gesetzt. Die Absenderergänzung wird dabei bei \opening überschrieben und steht nicht mehr für andere Inhalte zur Verfügung. Es ist jedoch möglich, weitere Variablen zu definieren und mit \addtoreffields zum Infoblock hinzuzufügen. Dabei kann mit \addtoreffields{vspacemarkerfield} auch ein vertikaler Abstand eingefügt werden. Die Grösse des Abstands wird von der Pseudolänge refvspace bestimmt. Wenn Sie das Beispiel selbst verwenden wollen, speichern Sie es bitte unter dem Namen infoblck.lco. Sie sollten allerdings wissen, dass dabei interne Makros des scrlttr2 Klasse verändert werden. Damit ist das ganze von der Version von scrlttr2 abhängig und funktioniert mit zukünftigen Versionen möglicherweise nicht mehr.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Letter Class Option generating an info block at
% `location' instead of reference line.
%
% Copyright (c) Torsten Krüger und Markus Kohm, 2002
%
 
\ProvidesFile{infoblck.lco}[%
  2002/06/28 LaTeX2e unsupported letter-class-option]
\@ifclassloaded{scrlttr2}{%
  \@ifclasslater{scrlttr2}{2002/06/28}{%
    \GenericWarning{%
      (infoblck.lco)\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces%
    }{%
      Letter-class-option infoblck Warning:\space
      This letter class option file was made\MessageBreak
      only to be used with KOMA-Script letter\MessageBreak
      class `scrlttr2' with version date\MessageBreak
      before 2002-06-28. Use with other\MessageBreak
      versions of `scrlttr2' may result in a\MessageBreak
      lot of errors or unexpected behaviour\@gobble
    }%
  }{}%
}{%
  \GenericWarning{%
    (infoblck.lco)\@spaces\@spaces\@spaces\@spaces\@spaces\@spaces%
  }{%
    Letter-class-option infoblck Warning:\space
    This letter class option file was made\MessageBreak
    only to be used with KOMA-Script letter\MessageBreak
    class `scrlttr2'. Use with other classes\MessageBreak
    may result in a lot of errors\@gobble
  }%
}
 
% First we define some dummy variable. They will never have a contents
% but are marks with special meaning. You should never use any of this
% variables but doing \addtoreffields{vspacemarkerfield} to add a
% vertical space at the info block.
\newkomavar{lastmarkerfield}   % internal: has to be only the last field
\newkomavar{vspacemarkerfield} % can be used to add vertical spaces
\newkomavar{datemarkerfield}   % internal: is used instead of `date'
 
% We use a new pseudo length. This is the amount of verticel space to
% be added with \addtoreffields{vspacemarkerfield}. Default is half of
% a base line skip.
\@newplength{refvspace}
\@setplength{refvspace}{.5\baselineskip}
 
% We need this macro at re-definition of \opening. It will be
% re-defined there. We will collect the table lines of the info block
% at this macro.
\newcommand*{\reffieldalllines}{}
 
% The alignment of the info block. Default is right align with
% \raggedleft:
\newcommand*{\raggedinfoblock}{\raggedleft}
 
% Now we re-define \opening, so it first will do some calculations and
% redefinitions and then call the original \opening (saved at \XOpening):
\newcommand*{\XOpening}{}
\let\XOpening\opening
\renewcommand*{\opening}{%
  % First we need more room beside the address to set the info
  % block. So we change meaning of locfield=wide and
  % locfield=narrow. Wide will be 90% instead of 67% and narrow will
  % be 75% instead of 50%.
  \ifdim \useplength{locwidth}=\z@
    \@setplength{locwidth}{\paperwidth}%
    \ifdim \useplength{toaddrhpos}>\z@
      \@addtoplength[-2]{locwidth}{\useplength{toaddrhpos}}%
    \else
      \@addtoplength[2]{locwidth}{\useplength{toaddrhpos}}%
    \fi
    \@addtoplength[-1]{locwidth}{\useplength{toaddrwidth}}%
    \if@bigloc
      \@setplength[.9]{locwidth}{\useplength{locwidth}}%
    \else
      \@setplength[.75]{locwidth}{\useplength{locwidth}}%
    \fi
  % Before we collect the table lines there should be no table lines:
  \let\reffieldalllines=\empty
  % The original definition of \@set@reffield sets a field of the
  % reference line. We change this that ...
  \renewcommand*{\@set@reffield}[1]{%
    \ifstr{##1}{lastmarkerfield}{%
      % ... at lastmarkerfield all collected table lines are put into
      % a table set into `location' variable,
      \setkomavar{location}{\raggedinfoblock
        \begin{tabular}{rl}
        \reffieldalllines
        \end{tabular}
      }%
    }{%
      \ifstr{##1}{vspacemarkerfield}{%
        % ... at vspacemarkerfield a vertical space will be collected,
        \l@addto@macro{\reffieldalllines}{%
          \noalign{\addvspace{\useplength{refvspace}}}%
        }%
      }{%
        \typeout{Field: ##1}%
        \ifstr{##1}{datemarkerfield}{%
          % ... at datemarkerfield the date from variable `date' will
          % be moved to to variable `datemarkerfield' ...
          \let\scr@datemarkerfield@var=\scr@date@var
          \let\scr@datemarkerfield@name=\scr@date@name
          % ... and variable `date' becomes empty,
          \setkomavar{date}{}%
        }{}%
        % ... all other variables are collected as table rows.
        \ifkomavarempty{##1}{}{%
          \l@addto@macro{\reffieldalllines}{%
            \scriptsize\sffamily\usekomavar*{##1}: & \usekomavar{##1}\\
          }%
        }%
      }%
    }%
  }%
  % We put the date to the info block using a dummy variable. But
  % before the date we add vertical space.
  \addtoreffields{vspacemarkerfield}%
  \addtoreffields{datemarkerfield}%
  % `lastmarkerfield' must be last field
  \addtoreffields{lastmarkerfield}%
  % Now, just run all \@set@reffield command ...
  \@set@reffields
  % ... and delete the reference line  ...
  \removereffields
  % ... before original \opening will be called.
  \XOpening
}
 
\endinput
%
% That's was the lco-file.
% See scrguide or scrguien about using lco-files.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Wie das ganze dann aussieht, entnehmen Sie bitte der PDF-Datei infoblock.pdf im Anhang.

Kommentare

Dieses Beispiel funktioniert in der aktuellen KOMA-Script-Release so nicht mehr. Siehe dazu auch die Diskussion im Forum.

Comments for "Beispiel für Infoblock statt Geschäftszeile" abonnieren