将日期位置设置为 NF.lco 中的右上角(法语风格)scrlttr2

将日期位置设置为 NF.lco 中的右上角(法语风格)scrlttr2

我想使用 KOMA-Script 类将日期放在收件人地址上方scrlttr2。我正在使用NF.lco\LoadLetterOption{NF}

在法语字母中,

  • 第一行包含日期,向右对齐
  • 然后左边的发件人地址
  • 然后右边的接收者地址
  • 然后是主题
  • ...

我可以使用优秀的lettre班级来自“日内瓦天文台”以获得正确的法语布局(见下文),但我受到我的 Org-Mode 导出scrlttr2作为 LaTeX 类使用的工具。

我怎么做 ?

事实上,我很想有一个 org-mode 工具来直接导出到lettre类中。另一种方法是在文件中重现“lettre”布局.lco。但这不是我的问题。

我可能没有读足够多的线性官方文档但是在其中对“日期”、“日期。*位置”、“位置”进行随机正则表达式搜索并没有给我满意的结果。

下面是我所拥有的以及我想要的的东西的说明

我拥有的

在此处输入图片描述

对于以下代码

\documentclass[a4paper,11pt,french]{scrlttr2}

\usepackage{palatino} 
\usepackage[T1]{fontenc} 
\usepackage{ucs} 
\usepackage[utf8x]{inputenc} 
\usepackage{eurosym} 
\usepackage{geometry} 
\usepackage{graphicx} 
\geometry{verbose,a4paper,lmargin=3cm,rmargin=3cm}

\setlength\parskip{\medskipamount} \setlength\parindent{0pt}

\usepackage{setspace} \usepackage{lipsum} \setstretch{1.15}

\LoadLetterOption{NF}%                         

\KOMAoptions{%
   fromalign=left% alignment of the address
  ,fromphone=true%         print sender phone number 
  ,fromemail=true%  print sender e-mail address  
  ,fromlogo=true%         print a logo (position depends on fromalign)
}

\setkomavar{date}{le \today}

\setkomafont{backaddress}{\rmfamily} 
\setkomafont{fromaddress}{\small} 
\setkomafont{fromname}{\scshape} 
\setkomavar{backaddressseparator}{ $\cdot$ } 
\setkomavar{backaddress}{}

\setkomavar{emailseparator}{~:~} \setkomavar{enclseparator}{ > } \setkomavar{fromaddress}{7-13 rue dejourney\\  49000 ANGERS} \setkomavar{fromemail}{[email protected]} \setkomavar{fromname}{Gigiair} \setkomavar{fromphone}{0123 456 789} \setkomavar{phoneseparator}{~:~} \setkomavar{place}{Angers} \setkomavar{signature}{\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad  \quad  \quad \includegraphics[width=2.5cm]{signature}} \setkomavar{subjectseparator}{ >>> } \setkomavar{subject}{Modèle}

\usepackage{babel}

\begin{document}


\begin{letter}{\`A Madame la centurion\\
    Camps de Babaurum\\
    Bretagne conquise}   \def\concname{Objet :~} 

  \opening{Madame la centurion,}   C'est une invitation pour manger du sanglier roti.   \closing{à la tienne !}

  \cc{Panoramix et Obleix} \end{letter} \end{document}

我想要的

在此处输入图片描述

来自以下代码

\documentclass[11pt, francais]{lettre} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage[francais]{babel} \usepackage{mathcomp} \usepackage{url}

\makeatletter \newcommand*{\NoRule}{\renewcommand*{\rule@length}{0}} \makeatother

\begin{document}

\begin{letter}   {\`A Madame la centurion
    \\Camps de Babaurum
    \\Bretagne conquise}   \def\concname{Objet :~}    \conc{Fête au village}

  \NoRule

  \name{Abraracourcix chef}   \address{Village des irréductibles Gaulois\\ Armorique}   \lieu{Bretagne Libre}

  \telephone{0123 456 789}   \nofax   \email{[email protected]}

  \opening{Madame la centurion,}   C'est une invitation pour manger du sanglier roti.   \closing{à la tienne !}

  \cc{Panoramix et Obleix}


\end{letter} \end{document}
添加 scrguien.pdf(KOMA-Script 手册)中的一页,以帮助其他读者访问此处

在此处输入图片描述

答案1

因为我不知道法语字母的规则(有没有*.lco针对讲法语的瑞士人的文件,类似于法国的字母?)所以我让你精确地解决它。

在你的情况下,你需要定义一个新的,firsthead例如:

\setkomavar{firsthead}{%
  \begin{tabular}[t]{l@{}}%
    \usekomavar{fromname}\\
    \usekomavar*{fromphone}\usekomavar{fromphone}\\
    \usekomavar*{fromemail}\usekomavar{fromemail}
  \end{tabular}
  \hfill
  \normalsize
  Angers, le \today % <=================================================
} 

请参阅我在上面的代码中直接添加了地点和日期(标记<======)。要使参考行中不打印地点和日期,您需要使用以下两行:

%\setkomavar{place}{Angers} 
\date{}

请参阅以下完整代码

\documentclass[%
  paper=a4,
  fontsize=11pt,
  french,
]{scrlttr2}

\usepackage{palatino} 
\usepackage[T1]{fontenc} 
\usepackage{ucs} 
\usepackage[utf8]{inputenc} 
\usepackage{babel}
\usepackage{eurosym} 

\usepackage{geometry} 
\usepackage{graphicx} 

\usepackage{setspace} 
\usepackage{lipsum}

\geometry{verbose,a4paper,lmargin=3cm,rmargin=3cm}

\setlength\parskip{\medskipamount} 
\setlength\parindent{0pt}

\setstretch{1.15}
\LoadLetterOption{NF}%

\KOMAoptions{% 
   fromalign=left% alignment of the address
  ,fromphone=true% print sender phone number
  ,fromemail=true% print sender e-mail address
  ,fromlogo=true% print a logo (position depends on fromalign) 
}

%\setkomavar{date}{le \today}
\setkomafont{backaddress}{\rmfamily} 
\setkomafont{fromaddress}{\small} 
\setkomafont{fromname}{\scshape} 
\setkomavar{backaddressseparator}{ $\cdot$ } 
\setkomavar{backaddress}{}

\setkomavar{emailseparator}{~:~} 
\setkomavar{enclseparator}{ > } 
\setkomavar{fromaddress}{7-13 rue dejourney\ 49000 ANGERS} 
\setkomavar{fromemail}{[email protected]} 
\setkomavar{fromname}{Gigiair} 
\setkomavar{fromphone}{0123 456 789} 
\setkomavar{phoneseparator}{~:~} 
%\setkomavar{place}{Angers} % <=========================================
\date{} % <============================================================
\setkomavar{signature}{\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \quad \quad \includegraphics[width=2.5cm]{example-image}} 
\setkomavar{subjectseparator}{ >>> } 
\setkomavar{subject}{Modèle}

\setkomavar{firsthead}{% <==============================================
  \begin{tabular}[t]{l@{}}%
    \usekomavar{fromname}\\
    \usekomavar*{fromphone}\usekomavar{fromphone}\\
    \usekomavar*{fromemail}\usekomavar{fromemail}
  \end{tabular}
  \hfill
  \normalsize
  Angers, le \today % <=================================================
}

\LoadLetterOption{visualize} % <========================================
\showfields{head,address,location,refline,foot} % <=====================


\begin{document}

\begin{letter}{`A Madame la centurion\ Camps de Babaurum\ Bretagne conquise} 
\def\concname{Objet :~}
\opening{Madame la centurion,} 
C'est une invitation pour manger du sanglier roti. 
\closing{à la tienne !}
\cc{Panoramix et Obleix} 
\end{letter} 
\end{document}

及其结果:

结果

请注意,的调用\LoadLetterOption{visualize}激活了的工具来scrarttl2可视化以命名的特殊字段\showfields{head,address,location,refline,foot}

如果这是法语字母的真正标准格式,请联系 KOMA-Script 的维护者https://komascript.de/ (您可以用英语书写)并提出功能请求以通过 pur lco 文件实现这种法语信件格式...

答案2

根据以下建议,您仍然可以使用\setkomavar{date}{...}和,并且您可以分别使用选项和\setkomavar{place}{...}启用/禁用和的使用。如果变量为空,则位置分隔符将被删除。fromphonefromemailfromphonefromemailplace

请注意,变量的内容firsthead会覆盖选项fromalignfromlogo。要删除反向地址,您可以设置选项backaddress=false。不要\parskip手动更改,而是使用选项parskip

\documentclass[a4paper,11pt,french]{scrlttr2}

\usepackage{palatino} 
\usepackage[T1]{fontenc}
\usepackage{babel}
%\usepackage[utf8]{inputenc}% not needed with an uptodate TeX Distribution
\usepackage{eurosym} 
\usepackage{geometry} 
\usepackage{graphicx} 
\geometry{verbose,a4paper,lmargin=3cm,rmargin=3cm}

\KOMAoptions{parskip=half-}%<- do not set \parskip manually

\usepackage{setspace}
\setstretch{1.15}

\usepackage{url}% <- added

\LoadLetterOption{NF}%

\KOMAoptions{%
  %fromalign=center% <- no effect because of \setkomavar{firsthead}{...}
  ,fromphone=true
  ,fromemail=true
  %,fromlogo=true% <- no effect because of \setkomavar{firsthead}{...}
  ,backaddress=false% <- remove backaddress
  ,refline=nodate% <- remove date from the refline
  ,subject=titled% <- use a title for the subject
}

\renewcaptionname{french}{\subjectname}{Objet}% like your lettre version
\addtokomafont{subject}{\normalfont}% <- like your lettre version

\renewcaptionname{french}{\ccname}{C.c.}% like your lettre version
\setkomavar{ccseparator}{}
\setkomavar*{ccseparator}{\llap{\ccname\quad}}% like your lettre version

\setkomavar{placeseparator}{, le }

\setkomafont{fromname}{\scshape}
\setkomafont{fromaddress}{\small}

\setkomavar{emailseparator}[E-Mail]{~:~}% <- like your lettre version
\setkomavar{enclseparator}{ > }
\setkomavar{fromaddress}{7-13 rue dejourney\\  49000 ANGERS}
\setkomavar{fromemail}{\url{[email protected]}}% <- like your lettre version
\setkomavar{fromname}{Gigiair}
\setkomavar{fromphone}{0123 456 789}
\setkomavar{phoneseparator}[Tél]{.~}% <- like your lettre version
\setkomavar{place}{Angers}
\setkomavar{signature}{\hspace{26em}\includegraphics[width=2.5cm]{example-image}}% <- changed
\setkomavar{subjectseparator}{~:~}% <- like your lettre version
\setkomavar{subject}{Modèle}

\makeatletter
\setkomavar{firsthead}{{%
  \usekomafont{fromaddress}%
  \parbox[b]{\useplength{firstheadwidth}}{%
    {\usekomafont{fromname}\usekomavar{fromname}}
    \hfill{\usekomafont{placeanddate}%
      \ifkomavarempty{place}{}{\usekomavar{place}\usekomavar{placeseparator}}%
      \usekomavar{date}%
    }%
    \\\usekomavar{fromaddress}%
    \medskip% similar to the lettre version
    \if@phone\\\usekomavar*{fromphone}\usekomavar{fromphone}\fi
    \if@mobilephone\\\usekomavar*{frommobilephone}\usekomavar{frommobilephone}\fi%
    \if@fax\\\usekomavar*{fromfax}\usekomavar{fromfax}\fi
    \if@email\\\usekomavar*{fromemail}\usekomavar{fromemail}\fi
    \if@www\\\usekomavar*{fromurl}\usekomavar{fromurl}\fi
  }}%
}
\makeatother

\begin{document}

\begin{letter}{\`A Madame la centurion\\
    Camps de Babaurum\\
    Bretagne conquise}
\def\concname{Objet :~} 

  \opening{Madame la centurion,}
  C'est une invitation pour manger du sanglier roti.
  \closing{à la tienne !}

  \cc{Panoramix et Obleix}
\end{letter}
\end{document}

结果:

截屏

相关内容