John, all

here is the complete letter with the accompanying Koma Letter Class
Option file, which either needs to be in the same directory or in one
which texhash (which MUST be run after each change) can find.

On MacTeX the file to look for is

        /usr/local/texlive/2021basic/texmf.cnf

on linux something like

        find /usr -name texmf.cnf

might help.

The variable to look for is

        TEXMFLOCAL = /usr/local/texlive/texmf-local

which in my case yields something like

        [...]
        32      /usr/local/texlive/texmf-local/tex/latex/misc
        1496    /usr/local/texlive/texmf-local/tex/latex/koma-script
        240     /usr/local/texlive/texmf-local/tex/latex/rangen
        [...]

and I have my own adapted *.lco in there, as homebrew (on the mac) makes
me own the tree below /usr/local and so I don't need sudo.

I think you can set up a similar tree below $HOME somehow, but I don't
use LyX/LaTeX on linux, so I don't know.

The letter is currently set up for DIN A4. In the LyX file as

        Document -? Settings... -> Page Layout (Default)

where for US formats it would need to be adapted, and in the LCO at the
top where you should comment out the DIN and un-comment the
UScommercial9.

If you want to know where they are

The letter and stamp require a number packages, so at the very least do:

        tlmgr install pgf xpatch lipsum hyperref xurl lastpage koma-script \
                luacode

packages that are installed already will cause a warning message.

I hope it's a complete list.

I like Google's NOTO fonts but if you don't, just change in the document
preamble (this is required for the stamp to work, but I have never
bothered to try to understand why it doesn't work properly when put
directly into the LyX Font page).

Iso you may need to

        tlmgr install noto

sudo may be required (of course).

I have put two paragraphs worth of lorem ipsum text in there, and if you
really want to play with it, wait for at least a minute, make small
change to the LyX file and regenerate, while the PDF viewer has it open.

You should see that the stamp will slightly rotate and move :-)-O

I also enclose a PDF for comparison, which was generated from the
command line using

        lyx -f -e pdf5 bookoff.lyx

It needs LUATEX (LuaLaTeX), pdflatex does NOT work (it uses LUA
internally to calculate some randomness).

I find really cool, that you can have seriously involved and complicated
LaTeX Voodoo without a single line of it bothering the (casual) user
:-)-O as it is all hidden in the preamble or in the LCO.


I am quite interested in positive comments and improvements to make
it faster, better or both.

I would be EXTREMELY interested in someone doing this over as a LyX
module, i.e. so that you can get additional fields in the LyX window and
that the stamp dimensions are then calculated dynamically, and this
sordid mess could perhaps even join the LyX project properly :-)-O

I have not the faintest clue how to do that, myself :-)-O and as it
works for me, no interested in hopping on that particular learning
curve :-)-O

greetings, el

On 2021-09-23 18:43 , Dr Eberhard W Lisse wrote:
john,

I'll share a complete example

[...]
On 23. Sep 2021, 17:43 +0200, John White <j...@whitelawchartered.com>, wrote:
On Thursday, September 23, 2021 4:25:57 AM PDT Dr Eberhard Lisse wrote:
[...]
Thanks Doc,

I have marked this email "important" and "action item."  When I get
some time I will try to figure it out.  It prints your letterhead
with some extraneous code.  Do not try to tell me how to fix it.  I
need to figure that out for myself.

Best,

John
#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass scrlttr2
\begin_preamble
\usepackage{noto}

%% LUA: Winkel des Gesamtstempels -- willk\"{u}rlich 
%% zwischen -5 und +5 Grad -- bei jedem Dokument anders
\usepackage{luacode}
\newcommand\rot{\directlua{tex.sprint(math.random(-5,5))}}

\usepackage{tikz}
\usepackage{xpatch}

%% XCOLOR: Farbdefinitionen
\definecolor{stampink}{RGB}{122 150 165}

%% LATEX: Individuelle Definitionen f\"{u}r den Stempel (Formatierung 
Gr\"{o}{\ss}e und Schriftstil)
\newcommand\myStampName{Dr Eberhard W Lisse}
\newcommand\myStampProf{Obstetrician \& Gynecologist}
\newcommand\myStampPO{PO Box 8421 Bachbrecht}
\newcommand\myStampNo{016-000-0141135}

\newcommand\myStampArrangement{%
   \setsansfont{Linux Biolinum O}
   \parbox{3cm}{%
      \centering\sffamily
      \footnotesize\myStampName\\
      \tiny\myStampProf\\
      \scriptsize\myStampPO\\
      \myStampNo\\
      \footnotesize\ISOToday
   }
   \setsansfont{IBM Plex Sans}
}

%% TIKZ: Laden notwendiger Styles
\usetikzlibrary{fit}

%% Erstellen eines Befehls f\"{u}r den Stempel in einer Gr\"{o}{\ss}e von 6 cm 
x 3 cm skaliert
\newcommand\Stamper{%
\resizebox{8cm}{3cm}{%
\begin{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% 
%% TIKZ: Setzen der linken unteren und rechten oberen Ecke des Rechtecks
\coordinate (dm1) at (0,0);
\coordinate (dm2) at (2.6,1.4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TIKZ: Schleife f\"{u}r drei Winkel
\foreach \r in {-0.9,0,0.9}{%
%% TIKZ: Rahmmen des Stempels: Rechteck, Farbe=stampink, Transparenz=0.4, 
Linienst\"{a}rke des Rahmens=1pt
%%       und einen Knoten namens (bx4) definieren
\node[rectangle,draw,stampink,opacity=.4,line width=1.2pt,rotate=\r, rounded 
corners=1pt][fit=(dm1)(dm2)](bx4){};
%% TIKZ: Stempeltext: Farbe=stampink, gedreht um den Winkel \r mit 
Transparenz=0.4 in Knoten (bx4) gesetzt
\node[stampink,rotate=\r,opacity=.4] at (bx4){\myStampArrangement};
}
\end{tikzpicture}
}}

%% SCRLTTR2 & XPATCH: Erstellen einer neuen Variablen f\"{u}r den Brief zur 
Positionierung des Stempels rechts von \closing
\newkomavar{rightbesidesignature}
\newlength{\normalparskip}
\xapptocmd{\closing}{%
  \setlength{\normalparskip}{\parskip}%
  \noindent\parbox[b][0pt]{\linewidth}{\raggedleft
    \setlength{\parskip}{\normalparskip}%
    \usekomavar{rightbesidesignature}\ifhmode\unskip\strut\fi
    \vspace{-1.8\baselineskip}%
    \vspace{\parskip}%
    \vspace{\lineskip}%
  }%
}{}{}

%% SCRLTTR2: Einf\"{u}gen des Stempels mit der jeweiligen willk\"{u}rlichen 
Gesamtdrehung \rot
\setkomavar{rightbesidesignature}{\rotatebox[origin=c]{\rot}{\Stamper}}
\end_preamble
\options drlisse
\use_default_options true
\maintain_unincluded_children false
\begin_local_layout
Format 66
PackageOptions fontspec no-math
Requires fontspec
\end_local_layout
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 85 85
\use_microtype true
\use_dash_ligatures true
\graphics default
\default_output_format pdf5
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize 10
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 0
\use_package amssymb 0
\use_package cancel 0
\use_package esint 0
\use_package mathdots 1
\use_package mathtools 0
\use_package mhchem 1
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Address
\begin_inset space ~
\end_inset


\end_layout

\begin_layout Title
Medical Certificate
\end_layout

\begin_layout Subject
Ms Jane Doe, DoB 1900-12-31
\end_layout

\begin_layout Myref
My Ref
\end_layout

\begin_layout Yourref
Your Ref
\end_layout

\begin_layout Yourmail
2021-08-01
\end_layout

\begin_layout Signature
Dr Eberhard W Lisse
\end_layout

\begin_layout Opening
\begin_inset space ~
\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Plain Layout


\backslash
lipsum[1-2]
\end_layout

\end_inset


\end_layout

\begin_layout Closing
With Kind Regards
\end_layout

\end_body
\end_document

Attachment: bookoff.pdf
Description: Adobe PDF document

%
% Load EITHER the DIN Letter from Koma Script or the US one by commenting
% out the other
% 
\LoadLetterOption{DIN}
%
%\LoadLetterOption{UScommercial9}
%
% Options
% 
\KOMAoptions{%
    addrfield=true%            print an address field?
    ,backaddress=true%         print the back address?
    ,enlargefirstpage=true%
    ,foldmarks=true%           print foldmarks?
    ,footsepline=false%        separate the footer with a line on page >1
    ,fromalign=center%         alignment of the address
    ,fromemail=false%          print sender e-mail address
    ,fromfax=false%            print sender fax number
    ,fromlogo=false%           print a logo (position depends on fromalign)
    ,fromphone=false%          print sender phone number
    ,fromrule=afteraddress%    separate the address with a line?
    ,fromurl=false%            print sender URL
    ,headsepline=false%        separate the header with a line on page >1
    ,pagenumber=botright%      position of the page number (see docu)
    ,parskip=half%             Use indent instead of skip
    ,refline=wide%             layout of the refline
    ,paper=a4%                 pagesize
}

% 
% set some lengths for the letter
% 
\makeatletter
\@setplength{sigindent}{0mm}
\@setplength{specialmailindent}{0truecm}
\@setplength{specialmailrightindent}{\fill}
\@setplength{refvpos}{89mm}
\@setplength{refaftervskip}{10pt}
\@setplength{firstfootvpos}{7cm}
\@addtoplength{firstfootvpos}{\textheight}
%
% NEW
%
\@addtoplength{firstfootvpos}{\footskip}
\makeatother

%
% Load some packages
% 
% If I want to test the letter output
% 
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% to get to the URLs with proper breaking, needs some work
% to survive turning this on in LyX
%
\usepackage{hyperref}
\hypersetup{%
   breaklinks=true,
   colorlinks=true,
   linkcolor=black,
   pdfborder={0 0 0},
   pdfborderstyle={},
   urlcolor=blue, 
}
\usepackage{xurl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\KOMAoptions{DIV=13}
%
% I like the ISO Date
% 
\providecommand*{\LCORequirePackage}[2][]{%
  \if@atdocument
    \scr@ifundefinedorrelax{ver@#2.sty}{%
      \GenericError{%
        (nanicmict.lco)\@spaces\@spaces\@spaces\@spaces
      }{%
        LCO-File nanicmict.lco Error: Package `#2' not loaded%
      }{%
        See the documentation of nanicmict.lco for explanation.%
      }{%
        This lco-file needs serveral packages. But packages can be loaded only
        before\MessageBreak
        \string\begin{document}. You've used the lco-file after
        \string\begin{document} so it cannot\MessageBreak
        load the needed packages.\MessageBreak
        You should either add \string\LoadLetterOption{nanic} before
        \string\begin{document}\MessageBreak
        or load package `#2' using \string\usepackage[#1]{#2}
        before\MessageBreak
        \string\begin{document}.
      }%
    }{}%
  \else
    \RequirePackage[#1]{#2}%
  \fi
}
\LCORequirePackage{scrdate}

%
% page # of ## pages
% 
\usepackage{lastpage}
%
% for the fancy header and footer formatting
% 
\usepackage[automark]{scrlayer-scrpage}

\pagestyle{scrheadings}

\firstfoot{%
   \centering{%
      \hrulefill\newline
      \footnotesize{%
         \textsf{%
            Practice Nr: 016-000-141135\\
            SWAMed Building 2$^{nd}$ Floor $\cdot$ John Meinert
            Street $\cdot$ Windhoek $\cdot$ Namibia\\
            Telephone: +264 61 236403 $\cdot$ Cell: +264 81 124
            6733 $\cdot$ Fax: +264 88 624273 $\cdot$
            Email: \href{mailto:d...@lisse.na}{d...@lisse.na}\\
            GPG Fingerprint: 7399 BE0B AEFB 4AE5 EDB9 4A54 9705 1DA3 7945 3FAB
         }
      }
   }
}
                


\clearscrheadfoot
\lohead[\usekomavar{fromname}]{\usekomavar{fromname}}
\rohead[\usekomavar{subject}]{\usekomavar{subject}}
%\ofoot[Page \pagemark\ of \pageref{LastPage}]
%      {Page \pagemark\ of \pageref{LastPage}}
\ofoot{Page \pagemark\ of \pageref{LastPage}}




%
% Sender's Name, in LARGE font, then practice details, since the 
% address goes into the footer
% 
\setkomavar{fromname}{\textsc{Dr Eberhard W Lisse}}
\setkomafont{fromname}{\LARGE}
\setkomavar{fromaddress}{Obstetrician \& Gynaecologist}
\setkomafont{fromaddress}{\large}

%
% default signature, left justified
%
\setkomavar{signature}{Dr Eberhard W Lisse}
\renewcommand*{\raggedsignature}{\raggedright}

%
% This goes in the Window of the envelope with a cosmetic separator 
% in netween each line
% 
\setkomavar{backaddress}{Dr Eberhard W Lisse\\
    PO Box 8421\\
    Bachbrecht\\10007\\
    Namibia}
\setkomavar{backaddressseparator}{ $\cdot$ }


% 
% redefine the reference line
% 
\AtBeginLetter{%
    \renewcaptionname{english}{\myrefname}{My ref.}
    \renewcaptionname{english}{\yourmailname}{Your letter}}
%
% Per default the captions are empty (and the ISO Date of today is 
% inserted, but this can be easily redefined in the letter
% 

\setkomavar{date}{\ISOToday}
\setkomavar{myref}{~}
\setkomavar{yourref}{~}
\setkomavar{yourmail}{~}

-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to