scrlttr2 所有页面(包括第一页)的页眉或页脚中的页码

scrlttr2 所有页面(包括第一页)的页眉或页脚中的页码

我正在尝试结合所有页面都有漂亮的页脚所有页面的页码firsthead=off因为我需要在后面的地址位置放一个徽标。如果我\chead*{\pagemark}从第一个链接中删除并添加\pagemark到,\setkomavar{firstfoot}我会得到页脚旁边的页码,如下所示:在此处输入图片描述

但我希望它处于这个位置在此处输入图片描述

如果需要,页脚可以占用按钮上的更多空间。如果页码位于顶部,也可以,就像第一个示例一样。这是我到目前为止的代码:

\documentclass[
fontsize=11pt, 
version=last, 
fromalign=left, 
backaddress=true, 
foldmarks=on, 
fromphone=off, 
fromemail=off, 
parskip=half, 
firsthead=off]{scrlttr2} 
%
 
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern}  
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{eso-pic}  


\usepackage{blindtext}
            
\renewcommand*\familydefault{\sfdefault}   

\renewcommand*{\raggedsignature}{\raggedright}  % Signatur wird bündig gesetzt

%
%--------------------------------------------------------------------------- 
% Absender
% 
\newcommand{\mVorname}{stupid company GmbH} 
\newcommand{\mNachname}{\& Co. KG} 
\newcommand{\mStrasse}{Somestreet. 1} 
\newcommand{\mStadt}{Somecity} 
\newcommand{\mPLZ}{22223} 
\setkomavar{date}{} 

\setkomavar{fromname}{\mVorname{}~\mNachname{}}               % Name 
\setkomavar{fromaddress}{\mStrasse{}\\{}\mPLZ{}~\mStadt{}}    % Adresse
\setkomavar{frombank}{SomeBank\\ 
            IBAN:DE00 0000 0000 0000 0000 00\\BIC: AAAAAAAAAAA}

\setkomavar{location}{\raggedright 
Versandanschrift:\\
\vfill
Some Guy   \\
23423 Blablubbing       \\ 
Blabistan               \\
Telefon
} 

\makeatletter
\@setplength{locvpos}{4.8cm}
\@setplength{locwidth}{7.5cm}
\@setplength{firstfootvpos}{250mm}
\makeatother

\LoadLetterOption{visualize}% loads visualize.lco to visualize boxes
\showfields{address}% show the address box


\renewcommand*\pagemark{%
  \usekomafont{pagenumber}{\pagename~\thepage~von~\letterlastpage}%
}

% header and footer first page:
\setkomavar{firstfoot}{% changed ->
  \usekomafont{pageheadfoot}%
  \parbox{\useplength{firstfootwidth}}{%
      \rule{\linewidth}{.4pt}\\
      \parbox[t]{0.31\linewidth}{%
        \begin{tabular}[t]{l}  
          \multicolumn{1}{@{}l@{}}{\textbf{Geschäftsinformation:}}\\ 
          persönlich haftende Gesellschafterin:\\ 
          stupid company Verwaltungs-GmbH\\
          Amtsgericht Somecity, HBR 111111 \\
          Handelsregister: Somecity HRA222222 \\
          \begin{tabular}{@{}l@{\;}l@{}}USt-IdNr.:& DE 000000000 \\
          WEEE-Nr.: & DE 00000000 \end{tabular}\\
          Geschäftsführer: Some Guy \\
          Sitz Somecity 
        \end{tabular}
      }%
      \hfill
      \parbox[t]{0.31\linewidth}{%
        \begin{tabular}[t]{l@{}}
          \multicolumn{1}{@{}l@{}}{\textbf{\usekomavar*{frombank}:}} \smallskip \\
          \usekomavar{frombank} \smallskip \\
          Somethirdbank  \\
          IBAN:DE00 0000 0000 0000 0000 00\\
          BIC: CCCCCCCCCCC
        \end{tabular}%
      }%
      \hfill
      \parbox[t]{0.31\linewidth}{%
        \begin{tabular}[t]{l@{}}
          \multicolumn{1}{@{}l@{}}{} \smallskip \\ 
          Someotherbank \\
          IBAN:DE00 0000 0000 0000 0000 00\\
          BIC: BBBBBBBBBBB
        \end{tabular}%
      }%
  }%
}
\setkomafont{pageheadfoot}{\scriptsize}

\usepackage{scrlayer-scrpage}% <- sets pagestyle scrheadings automatically
\DeclareNewLayer[
  foreground,
  textarea,
  voffset=\useplength{firstfootvpos},
  hoffset=\dimexpr.5\paperwidth-.5\useplength{firstfootwidth}\relax,
  width=\useplength{firstfootwidth},
  mode=picture,
  contents=\putUL{\raisebox{\dimexpr-\height}{\usekomavar{firstfoot}}}
]{likefirstpage.foot}

\AddLayersToPageStyle{scrheadings}{likefirstpage.foot}
\clearpairofpagestyles
\chead*{\pagemark}

\begin{document} 

%recipient  
\begin{letter}{%    
Max Musterkunde \\
Teststraße 2    \\
55555 Teststadt \\
Schweiz         \\ 
     }

 \AddToShipoutPicture{
    \begin{tikzpicture}[remember picture,overlay]
    \node[anchor=north east,yshift=-20.0pt,xshift=-10]%
        at (current page.north east)
        {\includegraphics[height=18mm]{example-image}};
    \node [anchor=north west,yshift=-20.0pt,xshift=47]%
        at (current page.north west)
        {\includegraphics[height=15mm]{example-image}};
    \node [anchor=south east,yshift=0pt,xshift=0]%
        at (current page.south east)
        {\includegraphics[height=13mm]{example-image}};
    \end{tikzpicture}
 }     

% 
%\setkomavar{title}{Titel} 
\setkomavar{subject}{BETREFF} 
% 
\opening{}
%

\Blindtext

\end{letter} 
\end{document} 

编辑:我把

    \begin{textblock*}{3cm}(9.5cm,28.5cm) % {block width} (coords) 
        \pagemark
    \end{textblock*}

firstfooter很愚蠢,但我还没有其他解决方案

答案1

要获得表格下方居中的页码,请添加:

\par\centering\pagemark\par

位于包含第三个表的 parbox 之后,但在外部 parbox 之内。

例子:

\documentclass[
  fontsize=11pt, 
  parskip=half, 
  firsthead=off
]{scrlttr2} 

\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{lmodern}
%\usepackage{amsmath}% not needed in this example
\usepackage{graphicx}

\usepackage{blindtext}% only for dummy text

\renewcommand*\familydefault{\sfdefault}
\renewcommand*{\raggedsignature}{\raggedright}

\newcommand{\mVorname}{stupid company GmbH} 
\newcommand{\mNachname}{\& Co. KG} 
\newcommand{\mStrasse}{Somestreet. 1} 
\newcommand{\mStadt}{Somecity} 
\newcommand{\mPLZ}{22223} 
\setkomavar{date}{} 

\setkomavar{fromname}{\mVorname{}~\mNachname{}}
\setkomavar{fromaddress}{\mStrasse{}\\{}\mPLZ{}~\mStadt{}}

\setkomavar{frombank}{SomeBank\\IBAN:DE00 0000 0000 0000 0000 00\\BIC: AAAAAAAAAAA}
\newcaptionname{ngerman}{\banknames}{Bankverbindungen}% caption name for more than one bank
\newkomavar[\banknames]{frombanks}% caption for more than one bank
\newkomavar[\usekomavar*{frombank}]{secondfrombank}
\setkomavar{secondfrombank}{Someotherbank\\IBAN:DE00 0000 0000 0000 0000 00\\BIC: BBBBBBBBBBB}
\newkomavar[\usekomavar*{frombank}]{thirdfrombank}
\setkomavar{thirdfrombank}{Somethirdbank\\IBAN:DE00 0000 0000 0000 0000 00\\BIC: CCCCCCCCCCC}

\setkomavar{location}{\raggedright 
  Versandanschrift:\\
  \vfill
  Some Guy\\
  23423 Blablubbing\\
  Blabistan\\
  Telefon
} 

\setplength{locvpos}{4.8cm}
\setplength{locwidth}{7.5cm}
\setplength{firstfootvpos}{250mm}

\LoadLetterOption{visualize}% loads visualize.lco to visualize boxes
\showfields{address}% show the address box

\renewcommand*\pagemark{%
  \usekomafont{pagenumber}{\pagename~\thepage~von~\letterlastpage}%
}

\setkomavar{firstfoot}{%
  \usekomafont{pageheadfoot}{% <- changed: { added
    \parbox{\useplength{firstfootwidth}}{%
      \rule{\linewidth}{.4pt}\\
      \parbox[t]{0.31\linewidth}{%
        \begin{tabular}[t]{l}
          \multicolumn{1}{@{}l@{}}{\textbf{Geschäftsinformation:}}\\ 
          persönlich haftende Gesellschafterin:\\ 
          stupid company Verwaltungs-GmbH\\
          Amtsgericht Somecity, HBR 111111 \\
          Handelsregister: Somecity HRA222222 \\
          \begin{tabular}{@{}l@{\;}l@{}}USt-IdNr.:& DE 000000000 \\
          WEEE-Nr.: & DE 00000000 \end{tabular}\\
          Geschäftsführer: Some Guy \\
          Sitz Somecity 
        \end{tabular}
      }%
      \hfill
      \parbox[t]{0.31\linewidth}{%
        \begin{tabular}[t]{l@{}}
          \multicolumn{1}{@{}l@{}}{\textbf{\usekomavar*{frombanks}:}} \smallskip \\% <- frombanks
          \usekomavar{frombank} \smallskip \\
          \usekomavar{thirdfrombank}
        \end{tabular}%
      }%
      \hfill
      \parbox[t]{0.31\linewidth}{%
        \begin{tabular}[t]{l@{}}
          \multicolumn{1}{@{}l@{}}{} \smallskip \\ 
          \usekomavar{secondfrombank}
        \end{tabular}%
      }%
      \par\centering\pagemark\par% <- centered pagemark added
}}}% <- changed: { added

\setkomafont{pageheadfoot}{\scriptsize}

\usepackage{scrlayer-scrpage}
\DeclareNewLayer[
  foreground,
  textarea,
  voffset=\useplength{firstfootvpos},
  hoffset=\dimexpr.5\paperwidth-.5\useplength{firstfootwidth}\relax,
  width=\useplength{firstfootwidth},
  mode=picture,
  contents=\putUL{\raisebox{\dimexpr-\height}{\usekomavar{firstfoot}}}
]{likefirstpage.foot}

\AddLayersToPageStyle{scrheadings}{likefirstpage.foot}
\clearpairofpagestyles

\DeclareNewLayer[
  background,
  page,
  addvoffset=20pt+.3333em,
  addhoffset=47pt+.3333em,
  addwidth=-47pt-.6666em,
  addheight=-20pt-.6666em,
  mode=picture,
  contents={%
    \putUR{\raisebox{\dimexpr-\height}{\makebox[0pt][r]{\includegraphics[height=18mm]{example-image}\hspace{10pt}}}}%
    \putUL{\raisebox{\dimexpr-\height}{\includegraphics[height=15mm]{example-image}}}%
    \putLR{\makebox[0pt][r]{\includegraphics[height=13mm]{example-image}}}%
  }
]{logos}
\AddLayersToPageStyle{@everystyle@}{logos}

\begin{document} 
\begin{letter}{%
  Max Musterkunde\\
  Teststraße 2\\
  55555 Teststadt\\
  Schweiz\\
}

  \setkomavar{subject}{BETREFF} 
  \opening{}
  \Blindtext
\end{letter} 
\end{document}

我删除了示例中不需要的选项。只有过时的 TeX 发行版才需要带inputenc选项的包。所有图层页面样式的和代码都被新图层所取代( )。utf8tikzeso-pic@everystyle@

在此处输入图片描述

相关内容