2

I am using scrlttr2 class of the KOMA-Script package and would like to have business title and name on the same line, with left-aligned title and right-aligned name, like shown at the picture.

Imgur

I've made some trick with \hspace and set of length commands (see MWE below):

\usepackage{calc}
\newcommand{\signedby}{John Dow}
\newcommand{\signedtitle}{CEO}
\newlength{\signedbylength}
\setlength{\signedbylength}{\textwidth-\widthof{\signedtitle}-\widthof{\signedby}}
\setkomavar{signature}{\signedtitle\hspace{\signedbylength}\signedby}

It works, but I am afraid that this is workaround and it can be done in some more elegant way?

MWE:

\documentclass[paper=a4, backaddress=off, 14pt, refline=nodate]{scrlttr2}
\usepackage{mweletter}
\usepackage[english]{babel}
\usepackage{calc}
\usepackage{lipsum}

% some trick
\newcommand{\signedby}{John Dow}
\newcommand{\signedtitle}{CEO}
\newlength{\signedbylength}
\setlength{\signedbylength}{%
    \textwidth-\widthof{\signedtitle}-\widthof{\signedby}}
\setkomavar{fromname}{Temporary Solutions, Inc.}
\setkomavar{fromaddress}{%
\textsf{\href{mailto:inbox@solutions.org}{inbox@solutions.org}}}
\setkomavar{signature}{\signedtitle\hspace{\signedbylength}\signedby}

\begin{document}
\begin{letter}{Ministry of Health\\
05000 Somewhere, Baker St., 7\\
\textsf{\href{mailto:inbox@mh.gov}{inbox@mh.gov}}}

\opening{}
\begin{center}
\normalfont\bfseries REQUEST\\
for information \normalfont
\end{center}\bigskip

\lipsum[1]

\noindent\closing{Sincerely,}
\noindent\today
\end{letter}
\end{document}

The mweletter package source:

% mweletter.sty
\ProvidesFile{mweletter.lco}
                        [2017/08/25 letter class option]
\RequirePackage[utf8]{inputenc}
\RequirePackage[%
    a4paper,pdftex,left=30mm,right=15mm,top=20mm,bottom=20mm%
    ]{geometry}
\RequirePackage{graphicx}
\RequirePackage{amsmath}
\RequirePackage{cmap}
\RequirePackage{color}
\RequirePackage{indentfirst}
\RequirePackage[T2A]{fontenc}
\RequirePackage[protrusion=true]{microtype} % Висячая пунктуация
\RequirePackage{enumitem}
\RequirePackage[unicode, colorlinks, pdfstartview=FitH, pdflang=UK]{hyperref}
\@setplength{toaddrvpos}{10mm}
\@setplength{toaddrhpos}{120mm}
\@setplength{toaddrheight}{0mm}
\@setplength{backaddrheight}{0pt}
\@setplength{firstheadvpos}{30mm}
\@setplength{firstheadhpos}{120mm}
\@setplength{refvpos}{70mm} % 110
\@setplength{subjectaftervskip}{\baselineskip}
\@setplength{backaddrheight}{10mm}
\setkomavar{date}{\flushleft\vspace{-\baselineskip}\today\par}
\@setplength{sigbeforevskip}{8mm}
\newcommand{\rom}[1]{%
  \textup{\uppercase\expandafter{\romannumeral#1}}%
}
\renewcommand\raggedsignature{}
\setlength{\parindent}{4ex}
\setlength{\itemsep}{0mm}

Any help is appreciated.

1

You can patch \closing to add the usage of a new variable:

\RequirePackage{filecontents}
\begin{filecontents*}{mweletter.sty}
\ProvidesFile{mweletter.lco}
                        [2017/08/25 letter class option]
\RequirePackage[utf8]{inputenc}
\RequirePackage[%
    a4paper,pdftex,left=30mm,right=15mm,top=20mm,bottom=20mm%
    ]{geometry}
\RequirePackage{graphicx}
\RequirePackage{amsmath}
\RequirePackage{cmap}
\RequirePackage{color}
\RequirePackage{indentfirst}
\RequirePackage[T2A]{fontenc}
\RequirePackage[protrusion=true]{microtype} % Висячая пунктуация
\RequirePackage{enumitem}
\RequirePackage[unicode, colorlinks, pdfstartview=FitH, pdflang=UK]{hyperref}
\@setplength{toaddrvpos}{10mm}
\@setplength{toaddrhpos}{120mm}
\@setplength{toaddrheight}{0mm}
\@setplength{backaddrheight}{0pt}
\@setplength{firstheadvpos}{30mm}
\@setplength{firstheadhpos}{120mm}
\@setplength{refvpos}{70mm} % 110
\@setplength{subjectaftervskip}{\baselineskip}
\@setplength{backaddrheight}{10mm}
\setkomavar{date}{\flushleft\vspace{-\baselineskip}\today\par}
\@setplength{sigbeforevskip}{8mm}
\newcommand{\rom}[1]{%
  \textup{\uppercase\expandafter{\romannumeral#1}}%
}
\renewcommand\raggedsignature{}
\setlength{\parindent}{4ex}
\setlength{\itemsep}{0mm}
\newkomavar{position}
\RequirePackage{xpatch}
\xpatchcmd\closing{\usekomavar{signature}}{\usekomavar{position}}{}{\failure}
\xpatchcmd\closing{\usekomavar{signature}}{\usekomavar{position}}{}{\failure}
\xpatchcmd\closing{\parbox}{\parbox[b]}{}{\failure}
\xpatchcmd\closing{\par}{\xpar}{}{\failure}
\xpatchcmd\closing{\par}{\hfill\strut\usekomavar{signature}\par}{}{\failure}
\xpatchcmd\closing{\xpar}{\par}{}{\failure}
\end{filecontents*}

\documentclass[paper=a4, backaddress=off, 14pt, refline=nodate]{scrlttr2}
\usepackage{mweletter}
\usepackage[english]{babel}
\usepackage{calc}
\usepackage{lipsum}

% some trick
\setkomavar{fromname}{Temporary Solutions, Inc.}
\setkomavar{fromaddress}{%
\textsf{\href{mailto:inbox@solutions.org}{inbox@solutions.org}}}
\setkomavar{signature}{John Dow}
\setkomavar{position}{CEO}

\begin{document}
\begin{letter}{Ministry of Health\\
05000 Somewhere, Baker St., 7\\
\textsf{\href{mailto:inbox@mh.gov}{inbox@mh.gov}}}

\opening{}
\begin{center}
\normalfont\bfseries REQUEST\\
for information \normalfont
\end{center}\bigskip

\lipsum[1]

\noindent\closing{Sincerely,}
\noindent\today
\end{letter}
\end{document}

enter image description here

But this does not work, if the signature has more than one line. In this case you have to encapsulate \usekomavar{signature} in a tabular, varwidth or \parbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.