sclrttr2 包:如何使用 fromlogo 变量?如何获取第二页的页脚?

sclrttr2 包:如何使用 fromlogo 变量?如何获取第二页的页脚?

我正在使用scrlttr2正式信函模板。我面临 3 个问题:


(1)首页页眉处显示Logo

我想要首页右上角的标题徽标标题行上方,如下图所示: 它看起来应该是这样的。

现在看起来是这样的(错误的方式): 现在的情况就是这样。


(2)所有页面页脚处均有 Logo

  • 我也希望在页脚中使用相同的徽标,在第一页和所有其他页面上。它必须看起来像这样: 它看起来应该是这样的。

现在看起来像这样(错误的方式): 在此处输入图片描述


(3)所有后续页面页眉中均显示徽标

在所有后续页面上,我希望徽标仍然存在,但没有联系方式。它必须看起来像这样: 在此处输入图片描述

现在它只是空的。


这就是我现在使用的代码:

\documentclass%%
  [fontsize=11pt,
   parskip=half,%%
   fromalign=right,%%
   fromphone=on,%%
   fromfax=on,%%
   fromrule=aftername,%%
   fromemail=on,%%  
   fromlogo=true,%%
   foldmarks=false,%%
   firstfoot=true,%%
   subject=titled,%%
   pagenumber=botright,%%
]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{url}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage{lipsum}
\usepackage{selinput}
\usepackage{newcent}
\usepackage{lipsum}
\SelectInputMappings{
  adieresis={ä},
  germandbls={ß},
  Euro={€},
}

\setkomafont{fromname}{\scshape \LARGE}
\setkomafont{backaddress}{\mdseries}

\makeatletter
\@setplength{firstheadvpos}{7mm}
\@setplength{firstfootvpos}{265mm}%%
\makeatother

\begin{document}

\setkomavar{fromaddress}{
    my surname name\\
    my streetname 21\\
    my example city}
\setkomavar{fromphone}{+99\,(9)999)\,999\,999\,99}
\setkomavar{fromphone}{+99\,(9)999)\,999\,999\,99}
\setkomavar{fromfax}{+99\,(9)999)\,999\,999\,99}
\setkomavar{fromemail}{[email protected]}
\setkomavar{backaddressseparator}{ - }
\setkomavar{place}{city}
\setkomavar{signature}{example signature}
\setkomavar{frombank}{IBAN: 9999\,9999\,9999\,9999\,9999\,99\\
  BIC: 12341234ABDC\\
  example example example\vspace{0.1cm}\\
  example example example example\\
  example example example, example example example}
\setkomavar{fromlogo}{\includegraphics[scale=.2]{/home/philipp/Dropbox/briefvorlage_example_TechExchange/generic_logo.pdf}}

\setkomavar{firstfoot}{\footnotesize%
  \rule[5pt]{472pt}{.3pt}\\
  \begin{tabular}[t]{l@{}}% 
    \usekomavar{fromname}\\
    \usekomavar{fromaddress}\\
  \end{tabular}%
  \hfill
  \begin{tabular}[t]{l@{}}%
    \usekomavar{fromphone}\\
    \usekomavar{fromfax}\\
    \usekomavar{fromemail}\\
  \end{tabular}%
  \ifkomavarempty{frombank}{}{%
    \hfill
    \begin{tabular}[t]{l@{}}%
      \usekomavar{frombank}
    \end{tabular}%
    }%
}%

\renewcaptionname{ngerman}{\enclname}{Anlagen}

\begin{letter}{Mr.\\surname name\\office\\street name\\postal code and city}\vspace{0.3cm}

\setkomavar{subject}{subject: example example example example example example example example example example example example example example example example example example example example example example example example}

\opening{Dear Mr. xxxxx xxxxxxxxxx,}

\lipsum[1-4]

\closing{Regards,}
\setkomavar*{enclseparator}{Enclosure(s):}

\encl{example enclosure}
\end{letter}
\end{document}

我研究了几个小时,但一无所获。这些是我查看过的最有用的帖子,不幸的是,没有任何成果:徽标置于标题栏中(将徽标置于标题中)LaTeX 标题中的徽标,Koma-Script 字母类页眉和页脚未显示在第二页(scrlttr2)

非常感谢您的帮助。

答案1

要解决这三个问题,您可以这样做:

  1. 第一页标题中的徽标:将徽标放在线上方,然后是地址等。我认为最好的方法是firsthead像这样定义自己的徽标:

    \setkomavar{firsthead}{\raggedleft % <==================================
      \usekomavar{fromlogo}\\[+1cm]
      \rule{\textwidth}{0.5pt}\\
      \usekomavar{fromaddress}\\
      \usekomavar{fromphone}\\
      \usekomavar{fromfax}\\
      \usekomavar{fromemail}\\% <===========================================
    }
    

    要激活此定义,请将该选项称为firsthead=true,类选项。

  2. 所有页面页脚中的徽标:首先,您必须像firstfoot这样添加徽标:

    \setkomavar{firstfoot}{\footnotesize%
      \rule[5pt]{472pt}{.3pt}\\
      \begin{tabular}[t]{l@{}}% 
        \includegraphics[scale=.3]{generic-logo-company}\\[-5mm] % <==================
        \usekomavar{fromname}\\
        \usekomavar{fromaddress}\\
      \end{tabular}%
      \hfill
      \begin{tabular}[t]{l@{}}%
        \usekomavar{fromphone}\\
        \usekomavar{fromfax}\\
        \usekomavar{fromemail}\\
      \end{tabular}%
      \ifkomavarempty{frombank}{}{%
        \hfill
        \begin{tabular}[t]{l@{}}%
          \usekomavar{frombank}
        \end{tabular}%
        }%
    }%
    

    然后你需要定义nextfoot如下内容:

    % nextfoot nexthead
    \setkomavar{nextfoot}{\hspace{-1.1cm}\parbox[b]{472pt}{\usekomavar{firstfoot}}}% <=======================
    
  3. 所有后续页面的页眉中均有徽标:要将线条和徽标添加到页眉,请调用类选项headsepline=true,并添加以下代码

    \pagestyle{myheadings}
    \markboth{}{\protect\includegraphics[scale=.3]{generic-logo-company}}
    

然后你会得到以下完整的 MWE:

\documentclass[%
  fontsize=11pt,
  parskip=half,%%
% fromalign=right,% right,locationright %% <============================
  firsthead=true, % <===================================================
  fromphone=on,%%
  fromfax=on,%%
  fromrule=aftername,%%
  fromemail=on,%%  
  fromlogo=true,%%
  foldmarks=false,%%
  firstfoot=true,%%
  subject=titled,%%
  pagenumber=botright,%%
  headsepline=true, % <=================================================
  DIN
]{scrlttr2}

\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{url}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage{newcent}
\usepackage{lipsum}
\usepackage{selinput}
\SelectInputMappings{
  adieresis={ä},
  germandbls={ß},
  Euro={€},
}

\setkomafont{fromname}{\scshape \LARGE}
\setkomafont{backaddress}{\mdseries}

\makeatletter
\@setplength{firstheadvpos}{7mm}
\@setplength{firstfootvpos}{265mm}%%
\makeatother
\setkomavar{firsthead}{\raggedleft % <==================================
  \usekomavar{fromlogo}\\[+1cm]
  \rule{\textwidth}{0.5pt}\\
  \usekomavar{fromaddress}\\
  \usekomavar{fromphone}\\
  \usekomavar{fromfax}\\
  \usekomavar{fromemail}\\% <===========================================
}


\begin{document}

\setkomavar{fromaddress}{
    my surname name\\
    my streetname 21\\
    my example city}
\setkomavar{fromphone}{+99\,(9)999)\,999\,999\,99}
\setkomavar{fromphone}{+99\,(9)999)\,999\,999\,99}
\setkomavar{fromfax}{+99\,(9)999)\,999\,999\,99}
\setkomavar{fromemail}{[email protected]}
\setkomavar{backaddressseparator}{ - }
\setkomavar{place}{city}
\setkomavar{signature}{example signature}
\setkomavar{frombank}{IBAN: 9999\,9999\,9999\,9999\,9999\,99\\
  BIC: 12341234ABDC\\
  example example example\vspace{0.1cm}\\
  example example example example\\
  example example example, example example example}
\setkomavar{fromlogo}{\includegraphics[scale=.5]{generic-logo-company}\vspace{-1.3cm}}

\pagestyle{myheadings}
\markboth{}{\protect\includegraphics[scale=.3]{generic-logo-company}}

\setkomavar{firstfoot}{\footnotesize%
  \rule[5pt]{472pt}{.3pt}\\
  \begin{tabular}[t]{l@{}}% 
    \includegraphics[scale=.3]{generic-logo-company}\\[-5mm] % <==================
    \usekomavar{fromname}\\
    \usekomavar{fromaddress}\\
  \end{tabular}%
  \hfill
  \begin{tabular}[t]{l@{}}%
    \usekomavar{fromphone}\\
    \usekomavar{fromfax}\\
    \usekomavar{fromemail}\\
  \end{tabular}%
  \ifkomavarempty{frombank}{}{%
    \hfill
    \begin{tabular}[t]{l@{}}%
      \usekomavar{frombank}
    \end{tabular}%
    }%
}%

% nextfoot nexthead
\setkomavar{nextfoot}{\hspace{-1.1cm}\parbox[b]{472pt}{\usekomavar{firstfoot}}}% <=======================

\renewcaptionname{ngerman}{\enclname}{Anlagen}

\begin{letter}{Mr.\\surname name\\office\\street name\\postal code and city}\vspace{0.3cm}

\setkomavar{subject}{subject: example example example example example 
  example example example example example example example example 
  example example example example example example example example 
  example example example}

\opening{Dear Mr. xxxxx xxxxxxxxxx,}

\lipsum[1-8]

\closing{Regards,}
\setkomavar*{enclseparator}{Enclosure(s)}

\encl{example enclosure}
\end{letter}
\end{document}

生成页面如下:

第一页

第 2 页:

第2页

顺便说一句:在德语字母中,行距Betrifft:不再使用...

答案2

这是一个可能有帮助的开始。

  1. 对于上面的徽标,请使用fromalign=locationright而不是\fromalign=right。我发现这需要在徽标本身之后添加一些垂直负空间,而我已将其插入 中fromlogo。您还需要调整loc...变量来定位此块。

  2. 对于页脚中的徽标,只需在需要的位置使用适当的包含图形即可

  3. 对于右侧页眉中的徽标,选择页面样式headings\markboth{}{logo code}。对于此下的规则,将其添加headsepline=true到类选项中。

这给出

取样头

首页页脚

标题

\documentclass%%
  [fontsize=11pt,
   parskip=half,%%
   fromalign=locationright,%%
   fromphone=on,%%
   fromfax=on,%%
   fromrule=aftername,%%
   fromemail=on,%%
   fromlogo=true,%%
   foldmarks=false,%%
   firstfoot=true,%%
   subject=titled,%%
   pagenumber=botright,%%
   headsepline=true
]{scrlttr2}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{url}
\usepackage{graphicx}
\usepackage{eurosym}
\usepackage{lipsum}
\usepackage{selinput}
\usepackage{newcent}
\usepackage{lipsum}
\SelectInputMappings{
  adieresis={ä},
  germandbls={ß},
  Euro={€},
}

\setkomafont{fromname}{\scshape \LARGE}
\setkomafont{backaddress}{\mdseries}


\begin{document}
\makeatletter
\@setplength{locheight}{58mm}
\@setplength{locwidth}{50mm}
\@setplength{locvpos}{10mm}
\@setplength{toaddrvpos}{24mm}
\@setplength{firstfootvpos}{265mm}%%
\makeatother

\setkomavar{fromaddress}{%
    my surname name\\
    my streetname 21\\
    my example city}
\setkomavar{fromphone}{+99\,(9)\,999\,999\,99}
\setkomavar{fromphone}{+99\,(9)\,999\,999\,99}
\setkomavar{fromfax}{+99\,(9)\,999\,999\,99}
\setkomavar{fromemail}{[email protected]}
\setkomavar{backaddressseparator}{ - }
\setkomavar{place}{city}
\setkomavar{signature}{example signature}
\setkomavar{frombank}{IBAN: 9999\,9999\,9999\,9999\,9999\,99\\
  BIC: 12341234ABDC\\
  example example example\vspace{0.1cm}\\
  example example example example\\
  example example example, example example example}
\setkomavar{fromlogo}{\includegraphics[scale=.2]{example-image-a}\vspace{-1cm}}

\pagestyle{myheadings}
\markboth{}{\protect\includegraphics[scale=.1]{example-image-a}}

\setkomavar{firstfoot}{\footnotesize%
  \rule[5pt]{472pt}{.3pt}\\
  \begin{tabular}[t]{l@{}}%
    \includegraphics[scale=.05]{example-image-a}\\[-5mm]
    \usekomavar{fromname}\\
    \usekomavar{fromaddress}\\
  \end{tabular}%
  \hfill
  \begin{tabular}[t]{l@{}}%
    \usekomavar{fromphone}\\
    \usekomavar{fromfax}\\
    \usekomavar{fromemail}\\
  \end{tabular}%
  \ifkomavarempty{frombank}{}{%
    \hfill
    \begin{tabular}[t]{l@{}}%
      \usekomavar{frombank}
    \end{tabular}%
    }%
}%

\renewcaptionname{ngerman}{\enclname}{Anlagen}

\begin{letter}{Mr.\\surname name\\office\\street name\\postal code and city}\vspace{0.3cm}

\setkomavar{subject}{subject: example example example example example example example example example example example example example example example example example example example example example example example example}

\opening{Dear Mr. xxxxx xxxxxxxxxx,}

\lipsum[1-4]

\closing{Regards,}
\setkomavar*{enclseparator}{Enclosure(s):}

\encl{example enclosure}
\end{letter}
\end{document}

相关内容