I'm trying to align the signature with the destination address in a french styled letter.
I could use the very good lettre class as mentioned in my previous question but I need scrlttr2
to reuse the org-mode koma export back-end.
I tried setting the position with the following commands:
Test 0
\makeatletter
\@setplength{sigindent}{-\useplength{refhpos}+\useplength{toaddrhpos}}}
\makeatother
Test 1
\setkomavar{signature}{Chef Abraracoursix,\\Un chef à toujours bras long.}
Test 2
\setkomavar{signature}{\hspace{26em}\includegraphics[width=2.5cm]
{example-image}}
Test 3
\setkomavar{signature}{\hspace{26em}
\begin{minipage}[t]{7cm}
{Chef Abraracoursix,\hfill \\Un chef à toujours bras long.}
\end{minipage}}
But the signature is stuck to the left.
Here is my full code and the result I'm looking for.
% Created 2019-04-08 lun. 11:20
% Intended LaTeX compiler: pdflatex
\documentclass{scrlttr2}
\usepackage[francais]{babel}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
% \usepackage{showframe} % to show the page boundaries from https://tex.stackexchange.com/questions/298246/signatures-side-by-side
% \usepackage{geometry}
% \geometry{verbose,a4paper,lmargin=3cm,rmargin=3cm}
\LoadLetterOption{visualize}
\showfields{head,foot,address,location,refline}
\LoadLetterOption{NF}
\renewcaptionname{french}{\subjectname}{Objet}
\renewcaptionname{french}{\ccname}{C.c.}
\KOMAoption{
,foldmarks=false
,refline=nodate
,subject=titled
,fromemail=false
,fromlogo=false
,fromphone=false
,fromurl=false
,backaddress=false
,foldmarks=false
}
% from name
\setkomavar{fromname}{Chef Abraracoursix}
\setkomafont{fromname}{\scshape}
%%%%%%%%%%%%%%%% HERE %%%%%%%%%%%%%%%%
% signature
%%%% test 1
% \setkomavar{signature}{Chef Abraracoursix,\\Un chef à toujours bras long.}
%%%% test 2
% \setkomavar{signature}{\hspace{26em}\includegraphics[width=2.5cm]{example-image}}% <- changed
%%%% test 3
% \setkomavar{signature}{\hspace{26em}
% \begin{minipage}[t]{7cm}
% {Chef Abraracoursix,\hfill \\Un chef à toujours bras long.}
% \end{minipage}}
%%%% test 4
\setkomavar{signature}{
\noindent \parbox[t]{0.5\linewidth}{Chef Abraracoursix,\hfill \\Un chef à toujours bras long.}
}
%%%%%%%%%%%%%%%% above %%%%%%%%%%%%%%%%
% from adress
\setkomavar{fromaddress}{Place du village,\\Erqy,\\Armorique}
\setkomafont{fromaddress}{\small}
% place and location
\setkomavar{place}{Erqy}
\setkomavar{placeseparator}{, le }
% other komavar
\setkomavar{ccseparator}{}
\setkomavar*{ccseparator}{\llap{\ccname\quad}}
% \usepackage{setspace} \usepackage{lipsum} \setstretch{1.15}
% \setlength\parskip{\medskipamount}
% \setlength\parindent{0pt}
% \setstretch{1.15}
\date{\today}
\makeatletter
% firsthead
\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
\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
}}
}
makeatletter
%%%% TEST 0
% \@setplength{sigindent}{-\useplength{refhpos}+\useplength{toaddrhpos}}}
\makeatother
\renewcommand*{\raggedsignature}{\raggedright}
\hypersetup{
pdfauthor={Chef Abraracoursix},
pdftitle={Invitation pour une banquet au sanglier Roti},
pdfcreator={Emacs 26.1 (Org mode 9.1.9)},
pdflang={French}}
\begin{document}
\setkomavar{subject}{Invitation pour une banquet au sanglier Roti}
\begin{letter}{
Capitaine Paulus Romanicus\\
Camp de Babaorum
Bretany}
\opening{Le Romain,}
Dans le cadre des rapports de bon voisinage et de notre hospitalité légendaire, nous vous invitons à festoyer avec nous sous le grand chêne, du coucher du soleil à l'aube, à la prochaine plein lune pour le mariage de la belle Fabala et de vigourix.
\closing{À la tienne !}
\end{letter}
\end{document}
Idealy I would like
\makeatletter
\@setplength{sigindent}{-\useplength{refhpos}+\useplength{toaddrhpos}}
\makeatother
to work as expected with pseudo-lenght given in https://i.stack.imgur.com/D2tu3.png
Best Answer
Your calculation
-\useplength{refhpos}+\useplength{toaddhpos}
does not result in a value, that moves the signature to the middle of the text area.In your example the value of
refhpos
is 0pt and the value oftoaddrhpos
is -10mm (given byNF.lco
). Your(I've remove one
}
, which was to much), would result in asigindent
of -10mm. This would result in a position 10mm left to the left edge of the text area. So it is not what you want.The image you've linked (which is figure 22.1 of the current KOMA-Script manual), is about address fields at the left side. You are using an address field on the right side. So
toaddrhpos
is the distance from the right paper edge to the right address field edge. It is negative (as told above). Therefhpos
has nothing to do with the position of the address field.Please have a look into table 22.1 in part II of the KOMA-Script manual and into the descriptions of the pseudo length in section 22.1 to see, how the values of
toaddhpos
,refhpos
andsigindent
are interpreted byscrlttr2
.You may try something like:
Or a more complicate but correct calculation:
Note: This does only work for
toaddrhpos
< 0.\paperwidth+\useplenth{toaddrhpos}
is the position of the right edge of the address field relative to the left edge of the paper. Subtracting\useplength{toaddrwidth}
results in the left edge of the address field relative to the left edge of the paper. Adding\useplength{toaddrindent}
results in the left edge of the address relative to the left edge of the paper. Butsigindent
is relative to the left edge of the text area not the paper. So we have to subtract the left margin, which is (in oneside documents for all pages)\oddsidemargin+1in
.Note: Since KOMA-Script 3.26
\setplength
instead of\@setplength
is recommended.\@setplength
is an internal command now. You should not longer use it. If you are using an outdated KOMA-Script release you still have to use\@setplength
. But in this case also expressions in the second argument would not be allowed. So you would have to use:or split the calculation into several
\@addtoplength
.Here is an example (using KOMA-Script >= 3.26), that illustrates the calculation:
Note, there were several other issues with your code:
is deprecated. Current
babel
warns:is wrong.
\KOMAoption
has two arguments. The first one is an option key, the second is a list of option values.To help users to find out what's wrong, the current prerelease of KOMA-Script shows the following error message with your wrong usage of
\KOMAoption
:As the help text of the error message explains:
would be correct.
Your definition of
firsthead
adds several significant but unwanted white spaces. See What is the use of percent signs (%) at the end of lines? for more information how to avoid them.There is also a warning message about usage of
\date
:So for
scrlttr2
you should useor just remove it, because
\today
is already the default.Last but not least, you have a
instead of
in your document preamble.