Accept attributes in inline image syntax
[multimarkdown] / XSLT / letterhead.xslt
1 <?xml version='1.0' encoding='utf-8'?>
2
3 <!-- XHTML-to-Memoir converter by Fletcher Penney
4         specifically designed for use with MultiMarkdown created XHTML
5
6         Uses the LaTeX memoir class for output
7
8         The first page can include letterhead graphic elements (e.g. logo)
9
10         It is simplified from the full memoir version, removing items
11                 not likely to be included in a letter or simple document
12
13         *Requires that you use the mmd-letterhead style package for LaTeX,
14                 which is available at http://fletcherpenney.net/XSLT_Files*
15
16         MultiMarkdown Version 2.0.b5
17         
18         $Id: letterhead.xslt 479 2008-01-12 23:04:13Z fletcher $
19 -->
20
21 <!-- 
22 # Copyright (C) 2007-2008  Fletcher T. Penney <fletcher@fletcherpenney.net>
23 #
24 # This program is free software; you can redistribute it and/or modify
25 # it under the terms of the GNU General Public License as published by
26 # the Free Software Foundation; either version 2 of the License, or
27 # (at your option) any later version.
28 #
29 # This program is distributed in the hope that it will be useful,
30 # but WITHOUT ANY WARRANTY; without even the implied warranty of
31 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32 # GNU General Public License for more details.
33 #
34 # You should have received a copy of the GNU General Public License
35 # along with this program; if not, write to the
36 #    Free Software Foundation, Inc.
37 #    59 Temple Place, Suite 330
38 #    Boston, MA 02111-1307 USA
39 -->
40
41         
42 <xsl:stylesheet
43         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
44         xmlns:html="http://www.w3.org/1999/xhtml"
45         version="1.0">
46
47         <xsl:import href="memoir.xslt"/>
48         
49         <xsl:output method='text' encoding='utf-8'/>
50
51         <xsl:strip-space elements="*" />
52
53         <xsl:template match="/">
54                 <xsl:apply-templates select="html:html/html:head"/>
55                 <xsl:apply-templates select="html:html/html:body"/>
56                 <xsl:call-template name="latex-footer"/>
57         </xsl:template>
58
59         <!-- rely on the mmd-letterhead style to set up paper size -->
60         <xsl:template name="latex-paper-size">
61         </xsl:template>
62         
63         <xsl:template name="latex-document-class">
64                 <xsl:text>\documentclass[oneside,article]{memoir}
65 \usepackage{layouts}[2001/04/29]
66
67
68 </xsl:text>
69         </xsl:template>
70
71         <xsl:template name="latex-header">
72                 <xsl:text>\usepackage{fancyvrb}                 % Allow \verbatim et al. in footnotes
73 \usepackage{graphicx}                   % To include graphics in pdf's (jpg, gif, png, etc)
74 \usepackage{booktabs}                   % Better tables
75 \usepackage{tabulary}                   % Support longer table cells
76 \usepackage[utf8]{inputenc}             % For UTF-8 support
77 \usepackage{xcolor}                             % Allow for color (annotations)
78
79 %\geometry{landscape}                   % Activate for rotated page geometry
80
81 %\usepackage[parfill]{parskip}  % Activate to begin paragraphs with an empty
82                                                                 % line rather than an indent
83
84
85 \def\myauthor{Author}                   % In case these were not included in metadata
86 \def\mytitle{Title}
87 \def\mykeywords{}
88 \def\mybibliostyle{plain}
89 \def\bibliocommand{}
90 \def\myrecipient{}
91
92 \VerbatimFootnotes
93 </xsl:text>
94         </xsl:template>
95
96         <xsl:template name="latex-intro">
97                                 <xsl:text>
98
99 %
100 %       PDF Stuff
101 %
102
103 %\ifpdf                                                 % Removed for XeLaTeX compatibility
104 %  \pdfoutput=1                                 % Removed for XeLaTeX compatibility
105   \usepackage[
106         plainpages=false,
107         pdfpagelabels,
108         pdftitle={\mytitle},
109         pagebackref,
110         pdfauthor={\myauthor},
111         pdfkeywords={\mykeywords}
112         ]{hyperref}
113   \usepackage{memhfixc}
114 %\fi                                                    % Removed for XeLaTeX compatibility
115
116 \ifx\recipient\undefined
117 \else
118         \addtodef{\myrecipient}{}{\recipient \\}
119 \fi
120
121 \ifx\recipientaddress\undefined
122 \else
123         \addtodef{\myrecipient}{}{\recipientaddress}
124 \fi
125
126 \ifx\mydate\undefined
127         \def\mydate{\today}
128 \fi
129
130 </xsl:text>
131         </xsl:template>
132
133         <xsl:template name="return-address">
134                 <xsl:call-template name="return-address-defaults"/>
135                 <xsl:text>% Create return address
136 \def\returnaddress{\raggedleft 
137 \footnotesize
138 \renewcommand{\baselinestretch}{1.1}
139
140 \textbf{\myauthor} \\}
141
142 \ifx\position\undefined
143 \addtodef{\returnaddress}{}{\textit{\defaultposition}}
144 \else
145         \addtodef{\returnaddress}{}{\textit{\position} \\}
146 \fi
147
148 \ifx\email\undefined
149 \addtodef{\returnaddress}{}{\textit{\defaultemail}
150
151 ~
152
153 }
154 \else
155         \addtodef{\returnaddress}{}{\textit{\email}
156
157 ~
158
159 }
160 \fi
161
162 \ifx\department\undefined
163 \addtodef{\returnaddress}{}{\textbf{\defaultdepartment}}
164 \else
165         \addtodef{\returnaddress}{}{\textbf{\department} \\}
166 \fi
167
168 \ifx\address\undefined
169 \addtodef{\returnaddress}{}{\defaultaddress}
170 \else
171         \addtodef{\returnaddress}{}{\address \\}
172 \fi
173
174 \ifx\phone\undefined
175 \addtodef{\returnaddress}{}{\defaultphone}
176 \else
177         \addtodef{\returnaddress}{}{Tel \phone \\}
178 \fi
179
180
181 \ifx\fax\undefined
182 \addtodef{\returnaddress}{}{\defaultfax}
183 \else
184         \addtodef{\returnaddress}{}{Fax \fax \\}
185 \fi
186
187 \ifx\web\undefined
188 \addtodef{\returnaddress}{}{\defaultweb
189 }
190 \else
191         \addtodef{\returnaddress}{}{ \web \\
192 }
193 \fi
194                 </xsl:text>
195         </xsl:template>
196         
197         <xsl:template name="return-address-defaults">
198                 <xsl:text>% Default info for return address
199 % These should include '\\' where appropriate for line endings
200
201 \def\defaultemail{}
202 \def\defaultposition{}
203 \def\defaultdepartment{}
204 \def\defaultaddress{}
205 \def\defaultphone{}
206 \def\defaultfax{}
207 \def\defaultweb{}
208
209 % Define height for logo and return address
210 \def\logoheight{1.5in}
211
212 % Define Logo or something for upper left corner
213 \def\coverlogo{}
214
215 % Define signature
216 \ifx\signature\undefined
217         \def\signature{~ \\ Sincerely, \\
218
219 \myauthor}
220 \else
221 \fi
222
223 </xsl:text>
224         </xsl:template>
225
226         <xsl:template name="latex-begin-body">
227                 <xsl:call-template name="return-address"/>
228                 <xsl:text>\usepackage{mmd-letterhead}
229 \begin{document}
230
231 % Layout settings
232 \setlength{\parindent}{0pt}
233
234 \mainmatter
235
236 % Use coverpage style
237 \thispagestyle{letterhead-cover}
238
239 % Insert return address
240
241 \begin{figure}[t]
242 \begin{adjustwidth}{-0.5in}{-0.5in}
243 \begin{minipage}[l][\logoheight]{4in}
244         \coverlogo
245         \vspace*{\fill}
246 \end{minipage} 
247 \hfill 
248 \begin{minipage}[r][\logoheight]{2in} 
249         {\renewcommand{\baselinestretch}{1.1}
250         \color{returnaddress}\returnaddress}
251         \vspace*{\fill}
252 \end{minipage}
253 \end{adjustwidth}
254 \end{figure}
255
256
257 \pagestyle{letterhead}
258 \large
259 % Return to main settings
260
261 \renewcommand{\baselinestretch}{1.2}
262 \setlength{\parskip}{12pt}
263
264 % Insert Recipient
265 \myrecipient
266
267 % Insert date
268 \mydate
269
270 </xsl:text>
271 </xsl:template>
272
273         <xsl:template name="latex-title">
274         </xsl:template>
275
276         <xsl:template name="latex-copyright">
277         </xsl:template>
278
279         <xsl:template name="latex-footer">
280                 <xsl:text>\signature
281                         
282 %
283 % Back Matter
284 %
285
286 \backmatter
287 %\appendixpage
288
289 %       Bibliography
290 \bibliographystyle{\mybibliostyle}
291 \bibliocommand
292
293 %       Glossary
294 \printglossary
295
296
297 %       Index
298 \printindex
299
300 \end{document}
301 </xsl:text>
302         </xsl:template>
303
304
305 </xsl:stylesheet>