aboutsummaryrefslogtreecommitdiff
path: root/summary/kaupaper.sty
blob: 505072a75436ebe0b9d7f731c9be2992e70a44a4 (plain)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
%%
%% This is file `kaupaper.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% kautools.dtx  (with options: `paper')
%% 
%% This is a generated file.
%% 
%% Copyright (c) 2011-2014 Stefan Berthold <stefan.berthold@kau.se>
%% 
%% This file is part of the kauthesis bundle.
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `author-maintained'.
%% 
%% The Current Maintainer and author of this work is Stefan Berthold.
%% 
%% This work consists of all files listed in manifest.txt.
%% 
%% kautools.dtx
%% Copyright (c) 2011-2015 Stefan Berthold <stefan.berthold@kau.se>
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{kaupaper}
    [2014/10/22 v1.15 Karlstad University kautools bundle]
\RequirePackage{xkeyval}
\PassOptionsToPackage{hypertexnames=false}{hyperref}

\define@cmdkeys[kua]{paper}[kua@]{author,title,subtitle,refprefix,reference,refnote,email,refstr,vanity,subdelimiter,label,summary,limitations,participation}
\define@cmdkeys[kua]{paperlist}[kua@]{printparticipation,tocline}
\setkeys[kua]{paper}{refstr=\reprintedname}

\ProcessOptionsX[kua]<paper>

\RequirePackage{kauparts}
\RequirePackage{ifthen}
\RequirePackage{tikz}

\RequirePackage{ragged2e}
\RequirePackage{hyphenat}

\RequirePackage{kaulanguage}

\AtBeginDocument{%
  \setname{reprintedname}{Reprinted from}{Ursprungligen publicertad i}%
  \setname{appendedpapersname}{List of Appended Papers}{Bifogade publiceringar}%
  \setname{participationname}{Comments on my Participation}{Kommentarer p\aa{} min medverka}%
  \setname{papername}{Paper}{Publicering}%
}

\newcounter{kua@section}
\newcounter{kua@equation}
\newcounter{kua@figure}
\newcounter{kua@table}

\newcounter{kua@paper}

\providecommand\thepaper{}
\providecommand\thepapertitle{}

\newcommand\kua@warning\relax
\newcommand\kua@dowarn{\gdef\kua@warning{\@latex@warning@no@line{List data created from the kaupaper environment was outdated. Rerun to get the lists right}}}
\AtEndDocument{\kua@warning}

\newcommand\kua@listof[4]{%
  \IfFileExists{\jobname.#1}%
    {% check whether empty file
      \newread\reader%
      \openin\reader\jobname.#1%
      \read\reader to \readmacro%
      \ifeof\reader%
        \textcolor{red}{\ldots{} will be available after the next \LaTeX{} run.}%
        \@starttoc{#1}%
        %\AtEndDocument{\@latex@warning@no@line{Rerun to get the list of #2 right}}%
        \kua@dowarn%
      \else% file not empty -> create list
        #3\@starttoc{#1}#4%
      \fi%
    }%
    {% file does not exist
      \textcolor{red}{\ldots{} will be available after the next \LaTeX{} run.}%
      \@starttoc{#1}%
      %\AtEndDocument{\@latex@warning@no@line{Rerun to get the list of #2 right}}%
      \kua@dowarn%
    }%
}
\newcommand\listofpapers[1][]{%
  \setkeys[kua]{paperlist}{printparticipation=yes,tocline=yes,#1}
  \section*{\appendedpapersname}%
  \ifthenelse{\equal{\kua@tocline}{yes}}{%
    \addcontentsline{toc}{section}{\appendedpapersname}%
  }{}%
  \kua@listof{pap}{appended papers}{%
    \begin{enumerate}%
    \renewcommand\theenumi{\textbf{\Roman{enumi}}}%
  }{\end{enumerate}}%
  \ifthenelse{\equal{\kua@printparticipation}{yes}}{%
    \subsection*{\participationname}%
    \kua@listof{pcp}{participation in appended papers}{}{}%
  }{}%
}

\newcommand\l@paper[2]{%
  \item #1%
}

\newcommand\listofsummaries{%
  \kua@listof{sum}{paper summaries}{}{}%
}

\newcommand\l@summary[2]{%
  #1%
}

\newcommand\l@limit[2]{%
  %\paragraph{Limitations.}
  #1%
}

\newcommand\l@participation[2]{%
  #1%
}

\newcommand\papercover{%
  \begin{tikzpicture}[remember picture,overlay]%
    \path (current page.center)%
      node%
        [ node distance=\baselineskip%
        , text width=\textwidth%
        , text centered%
        ] (refstr) {\kua@refstr};%
      \ifthenelse{\equal{\kua@subtitle}{}}{%
        \node%
          [ node distance=1.5\baselineskip%
          , above=of refstr%
          , text width=\textwidth%
          , text centered%
          , font=\LARGE\bfseries%
          ] {\nohyphens{\kua@title}};%
      }{%
        \node%
          [ node distance=1.5\baselineskip%
          , above=of refstr%
          , text width=\textwidth%
          , text centered%
          , font=\large\bfseries%
          ] (sub) {\nohyphens{\kua@subtitle}};%
        \node%
          [ node distance=1pt%
          , above=of sub%
          , text width=\textwidth%
          , text centered%
          , font=\LARGE\bfseries%
          ] {\nohyphens{\kua@title}};%
      }%
      \node%
        [ node distance=\baselineskip%
        , below=of refstr%
        , text width=\textwidth%
        , text centered%
        , font=\large%
        ] {\nohyphens{\kua@reference}\ifthenelse{\equal{\kua@refnote}{}}{}{\mbox{}\\\medskip\nohyphens{\kua@refnote}}}%
    ;%
  \end{tikzpicture}%
}

\newenvironment{kaupaper}[1][]{%
  \setcounter{kua@section}{\value{section}}%
  \setcounter{kua@equation}{\value{equation}}%
  \setcounter{kua@figure}{\value{figure}}%
  \setcounter{kua@table}{\value{table}}%
  \setcounter{section}{0}%
  \setcounter{equation}{0}%
  \setcounter{figure}{0}%
  \setcounter{table}{0}%
  \setkeys[kua]{paper}{subtitle=,vanity=,subdelimiter={---},refprefix=,refnote=,label=,summary={\string\textcolor{red}{Use the \string\texttt{summary} key in the \string\texttt{kaupaper} environment to add a summary.}},participation={\string\textcolor{red}{Use the \string\texttt{participation} key in the \string\texttt{kaupaper} environment to add a comment.}},limitations={},#1}%
  \setcounter{kua@paper}{\value{kup@part}}\stepcounter{kua@paper}%
  \kaupart[tocentry=false,label=\kua@label,body=\papercover\kua@vanity]{\papername}%
  \ifthenelse{\equal{\kua@subtitle}{}}%
    {\ifthenelse{\equal{\kua@refnote}{}}%
      {\addcontentsline{pap}{paper}{\kua@author. \kua@title. \kua@refprefix\kua@reference.}}%
      {\addcontentsline{pap}{paper}{\kua@author. \kua@title. \kua@refprefix\kua@reference.\smallskip\\\kua@refnote}}%
     \addcontentsline{toc}{part}{\textsc{\papername} \Roman{kua@paper}: \\\kua@title}}%
    {\ifthenelse{\equal{\kua@refnote}{}}%
      {\addcontentsline{pap}{paper}{\kua@author. \kua@title\kua@subdelimiter\kua@subtitle. \kua@refprefix\kua@reference.}}%
      {\addcontentsline{pap}{paper}{\kua@author. \kua@title\kua@subdelimiter\kua@subtitle. \kua@refprefix\kua@reference.\smallskip\\\kua@refnote}}%
     \addcontentsline{toc}{part}{\textsc{\papername} \Roman{kua@paper}: \\\kua@title\kua@subdelimiter\kua@subtitle}}%
  \addcontentsline{sum}{summary}{\string\subsubsection*{\papername~\Roman{kua@paper} -- \kua@title}\kua@summary}%
  \ifthenelse{\equal{\kua@limitations}{}}{}{%
    \addcontentsline{sum}{limit}{\kua@limitations}}%
  \addcontentsline{pcp}{participation}{\string\paragraph{\papername~\Roman{kua@paper}}\kua@participation}%
  \renewcommand*\thepaper{\papername~\Roman{kua@paper}}%
  \renewcommand*\thepapertitle{\kua@title}%
  \renewcommand\maketitle{%
    \thispagestyle{plain}%
    \centering%
      \Large\bfseries%
      \vspace*{0.15\textheight}%
      \kua@title\par%
      \addvspace{1ex}%
      \ifthenelse{\equal{\kua@subtitle}{}}{}{\large\kua@subtitle}%
      \par\addvspace{\baselineskip}%
      \normalsize%
      \kua@author\\[0.25\baselineskip]%
      \normalfont%
    \par\addvspace{2\baselineskip}\justifying%
  }%
}{%
  \setcounter{section}{\value{kua@section}}%
  \setcounter{equation}{\value{kua@equation}}%
  \setcounter{figure}{\value{kua@figure}}%
  \setcounter{table}{\value{kua@table}}%
  \clearpage%
}
\endinput
%%
%% End of file `kaupaper.sty'.