-
Notifications
You must be signed in to change notification settings - Fork 2
/
SYSUletter.cls
155 lines (139 loc) · 5.01 KB
/
SYSUletter.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
%
% FDUletter.cls -- a document class for writing letters with OSU letterhead
% This class based on "brownletter.cls" Copyright 2003, Nesime Tatbul ([email protected])
%
% This version modifications by Huang Weiran
% ([email protected]), 28 October 2019
%
% New version modifications by Fanchao Chen
% ([email protected]), 23 October 2021
% Notes:
%
% 1. This class can be used for creating letters with FDU logo at the
% header and department address at the footer
% 2. It is based on the standard Latex document class, letter.cls.
% 3. Required packages are epsfig and ifthen.
% 4. If FDU logo is to be included in the head, then the file
% FDUlogo.eps must be provided. Otherwise, the logo is omitted.
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{SYSUletter}
\RequirePackage{graphicx}
\RequirePackage{epstopdf}
\RequirePackage{epsfig}
\RequirePackage{ifthen}
\RequirePackage{xcolor}
\definecolor{slcolor}{HTML}{882B21}
%\RequirePackage{fontspec}
\DeclareGraphicsExtensions {.png} %{.pdf}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{letter}}
\ProcessOptions
\LoadClass[letterpaper]{letter} % we always use letter paper
\newcommand{\subjectname}{Subject}
\newcommand{\@subject}{}
\newcommand{\subject}[1]{\renewcommand{\@subject}{\subjectname: #1}}
\newboolean{logofound}
\IfFileExists{sysu.png}
{\setboolean{logofound}{true}}
{\setboolean{logofound}{false}}
\setlength{\textwidth}{6.875in}
\setlength{\textheight}{7.0in}
\setlength{\topskip}{0.0in}
\setlength{\footskip}{1.0in}
\setlength{\oddsidemargin}{-0.25in}
\setlength{\evensidemargin}{-0.25in}
\setlength{\topmargin}{-0.875in}
\DeclareFixedFont{\xcmrbn}{OT1}{cmr}{b}{n}{10}
\DeclareFixedFont{\xcmrmn}{OT1}{cmr}{m}{n}{10}
\DeclareFixedFont{\ixcmrmn}{OT1}{cmr}{m}{n}{9}
\newsavebox{\departmenthead}
\newsavebox{\departmentfoot}
\newsavebox{\emptyfoot}
\sbox{\departmenthead}{
\begin{tabular*}{\textwidth}
{@{}l@{\extracolsep{0.0in}}|@{\extracolsep{0.125in}}l@{}}
% HELP FOR SETTING UP PARBOXES
% \parbox[position][height][inner-pos]{width}{text}
% The \parbox has two mandatory arguments:
% width - specifies the width of the parbox, and
% text - the text that goes inside the parbox.
% LaTeX will position a parbox so its center lines up with the center of the text line. The optional position argument allows you to line up either the top or bottom line in the parbox (default is top).
% If the height argument is not given, the box will have the natural height of the text.
% The inner-pos argument controls the placement of the text inside the box. If it is not specified, position is used.
% t -- text is placed at the top of the box.
% c -- text is centred in the box.
% b -- text is placed at the bottom of the box.
%LOGO
%
\parbox{4.00in}
{\raggedright
\ifthenelse{\boolean{logofound}}
{\epsfig{file=sysu.png, height=0.95in}}
{\parbox[c][2.0in][c]{4.0in}{\hfill}
\ClassWarning{FDUletter}{sysu.png COULD NOT BE FOUND!}}
} &
%DEPARTMENT OR SCHOOL
% This just sets the size of the box to the right of the logo, and the size of the vertical line. The vertical line is set by the size of the first numerical argument of the \parbox command.
%
% In the future, the "From" address might be better set using "tikz".
\parbox[c][1.8in][c]{2.225in}{{~}\\
}\\
\end{tabular*}
}
\savebox{\emptyfoot}[\textwidth][c]{\ixcmrmn
\hspace*{\textwidth}
}
% header and footer should be placed only on the first page
\renewcommand{\ps@firstpage}{
\setlength{\headheight}{1.375in}
\setlength{\headsep}{1.0in}
\renewcommand{\@oddhead}{\usebox{\departmenthead}}
\renewcommand{\@oddfoot}{\usebox{\departmentfoot}}
\renewcommand{\@evenhead}{}
\renewcommand{\@evenfoot}{}
}
\renewcommand{\ps@empty}{
\setlength{\headheight}{1.375in}
\setlength{\headsep}{0.5in}
\renewcommand{\@oddhead}{}
\renewcommand{\@oddfoot}{\usebox{\emptyfoot}}
\renewcommand{\@evenhead}{}
\renewcommand{\@evenfoot}{\usebox{\emptyfoot}}
}
\providecommand{\@evenhead}{}
\providecommand{\@oddhead}{}
\providecommand{\@evenfoot}{}
\providecommand{\@oddfoot}{}
\pagestyle{empty}
% we add the subject command to the opening
\renewcommand{\opening}[1]{\thispagestyle{firstpage}%
\ifx\@empty\fromaddress
%{\raggedleft\@date\par}%
\else % home address
{\raggedleft
\begin{tabular}{l@{}}\ignorespaces
\fromaddress \\ *[1\parskip]%
%\@date
\end{tabular}\par
}%
\fi
\vspace{-6\parskip}
\@date \vspace{2\parskip}\\
{\raggedright \toname \\ \toaddress \par}%
\vspace{1\parskip}%
\ifthenelse{\equal{\@subject}{}}{}{\@subject\par}
\vspace{1\parskip}%
#1\par\nobreak
}
% we push closing to the right
\renewcommand{\closing}[1]{\par\nobreak\vspace{\parskip}%
\stopbreaks
\noindent
\hspace*{0.6\textwidth}\parbox{0.4\textwidth}{\raggedright
\ignorespaces #1\\[4\medskipamount]%
\ifx\@empty\fromsig
\fromname
\else \fromsig
\fi\strut}%
\par
}