-
Notifications
You must be signed in to change notification settings - Fork 0
/
answerjh.sty
295 lines (251 loc) · 10.3 KB
/
answerjh.sty
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
% answerjh.sty 2001-May-23
\typeout{2001-May-23 Document Style `answerjh'. Jim Hefferon}
\RequirePackage[single,nowrite]{bookans} %!!! no write !!! else ereases answers
\RequirePackage{bookjh,linalgjh}
% PAGE DIMENSIONS
% \usepackage{vmargin}
% \setmarginsrb{1in}{1in}{1in}{1in}%
% {12pt}{4pt}{0pt}{0pt}
\geometry{margin=1in}
% HEADERS and FOOTERS
\RequirePackage{fancyhdr}
\pagestyle{fancyplain}
\lhead[\fancyplain{}{\thepage}]{\fancyplain{}{\textit{Answers to Exercises}}}
\chead[\fancyplain{}{}]{\fancyplain{}{}}
\rhead[\fancyplain{}{\textit{Linear Algebra, by Hef{}feron}}]{%
\fancyplain{}{\thepage}}
\lfoot[\fancyplain{}{}]{\fancyplain{}{}}
\cfoot[\fancyplain{\thepage}{}]{\fancyplain{}{}}
\rfoot[\fancyplain{}{}]{\fancyplain{}{}}
%\setlength{\footrulewidth}{0pt}
\setlength{\headwidth}{\textwidth}
\addtolength{\footskip}{9pt}
%\renewcommand{\p@theorem}{\relax}
% jh; stuff I often use
% Changed to support new kind of enumeration environment jh 90-7-10
\def\labelenumi{(\arabic{enumi})}
\def\theenumi{\arabic{enumi}}
\def\labelenumii{\(\bullet\)}
\def\theenumii{\alph{enumii}}
\def\p@enumii{\theenumi}
\def\labelenumiii{(\roman{enumiii})}
\def\theenumiii{\roman{enumiii}}
\def\p@enumiii{\theenumi(\theenumii)}
\def\labelenumiv{\bf --}
\def\theenumiv{\Alph{enumiv}}
\def\p@enumiv{\p@enumiii\theenumiii}
\def\labelitemi{$\bullet$}
\def\labelitemii{\bf --}
\def\labelitemiii{$\ast$}
\def\labelitemiv{$\cdot$}
% ANSWERLIST
% Answers are set inside this list.
\newcounter{answerlistcounter}
\newcommand{\answerlabel}[1]{{\bfseries #1}}
\newenvironment{answerlist}{%
\begin{list}{\relax
}{\usecounter{answerlistcounter}
\renewcommand{\makelabel}{\answerlabel}
\setlength{\leftmargin}{1em}
\setlength{\rightmargin}{0em}
\setlength{\parsep}{\parskip}
\setlength{\itemsep}{.7ex plus .5ex minus .3ex}
\setlength{\itemindent}{0em}
\setlength{\listparindent}{\parindent}
\setlength{\topsep}{.5ex plus .5ex minus .3ex}
\setlength{\partopsep}{0ex plus .5ex minus .1ex}
\setlength{\labelsep}{.8em}
\setlength{\labelwidth}{0em}
\setlength{\abovedisplayskip}{3pt plus2pt minus3pt}%
\setlength{\belowdisplayskip}{\abovedisplayskip}
\setlength{\abovedisplayshortskip}{0pt plus2pt}%
\setlength{\belowdisplayshortskip}{3pt plus2pt minus3pt}
}
}{\end{list}%
}
% An \item in the answerlist is made by \begin{ans}{One.II.3.4} .. \end{ans}
% They were put there by answer.sty on LaTeX-ing the book.
% \ifhrefout
% \renewenvironment{ans}[1]{\item[\hyperref{book.pdf}{exercise}{#1}{#1}\hypertarget{ans.#1}{}]}{%
% }
% \else
% \renewenvironment{ans}[1]{\item[#1]}{%
% }
% \fi
\renewenvironment{ans}[1]{%
\begin{answerlist}%
\ifinsidetopic
\item[\hyperref{book.pdf}{exercise}{\thesubsection.#1}{#1}\hypertarget{ans.\thesubsection.#1}{}]
\else
\item[\hyperref{book.pdf}{exercise}{#1}{#1}\hypertarget{ans.#1}{}]
\fi }{%
\end{answerlist}
}
% \answerspacer
% \answerdivider
% Visual candy put into answer files to separate answers from different
% sections and chapters.
%\newcommand{\answerspacer}{\relax}
%\newcommand{\answerdivider}{\vspace{5ex plus 2ex minus 1ex}\hbox to \textwidth{\rule{0in}{.25in}
% \leaders\hbox to 1em{\hss.\hss}\hfill}}
%=======================================
% Disclaimer that the answer is as in the published source for the question.
\newcommand{\answerasgiven}{%
\textit{This is how the answer was given in the cited source. }}
%--------exparts and exparts*
% For exercises with sub-parts. The *-ed version prints them across:
% (a) xxx (b) yyy (c) zzz ..
% while the un-*-ed version prints them down:
% (a) xxx
% (b) yyy
% Use this way:
% \begin{exparts}
% \partitem % not just \item so works in *-ed version.
% \end{exparts}
% Remark: I don't think I can use, say, paralist. I *don't* want:
% (a) Yes. (b) No; the reason is that we cannot
% find any counterexample (c) Yes.
% and I lack the TeX skills to automate the job of selecting the
% *-ed or un-*-ed version depending.
%
\renewenvironment{exparts}{%
\def\partsitem{\item\relax}%
\begin{expartslist}%
}{%
\end{expartslist}}
%
\renewenvironment{exparts*}{%
\def\partsitem{\penalty-400\hskip1.25em\relax\hbox{%
\refstepcounter{expartscount}\textbf{(\alph{expartscount})}\hspace*{.5em}}\nobreak}
\begin{expartslist}
\setlength{\itemindent}{-1.25em}
\rightskip=0pt plus7em\spaceskip=.3333em\xspaceskip=.5em\relax%
\item[]}{%
\end{expartslist}}
%
\renewenvironment{expartslist}{%
\begin{list}{\textbf{(\alph{expartscount})}}{
\usecounter{expartscount}
\setlength{\leftmargin}{1em}
\setlength{\rightmargin}{0em}
\setlength{\listparindent}{\parindent}
\setlength{\itemindent}{0em}
\setlength{\labelsep}{.4em}
\setlength{\labelwidth}{0em}
\setlength{\topsep}{0ex}
\setlength{\parskip}{0ex}
\setlength{\partopsep}{0ex}
\setlength{\parsep}{0ex}
\setlength{\itemsep}{0ex}
}%
}{%
\end{list}}
%
%...........end: exparts and exparts*
%\renewcommand{\thechapter}{\Englishnumber{\value{chapter}}}
\renewcommand{\thesection}{\thechapter.\Roman{section}}
\renewcommand{\chaptermark}[1]{% docs in fancyheadings.
\markboth{\chaptername~\thechapter. #1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{Section~\Roman{section}. #1}}
%\renewcommand{\thesubsection}{\arabic{subsection}}
%end headings
%\renewcommand{\subsection}{\@startsection%
% {subsection}{2}{0em}{10ex plus1ex minus1ex}{1em}%
% {\raggedright\large\bfseries}}
% Format the answer label.
\renewcommand{\ansparams}{{\Currentlabel}}
% CROSS REFERENCES
% References in the answers that are hypered are not internal to the
% answer file; they need to link to the book file.
\newcommand{\bookname}{book.pdf}
%\makeatletter
\ifhrefout
\newcommand{\bookreference}[2]{% #1=ref type (`Definition', etc.), #2=ref
\def\jhans@anchorname{% name like `theorem.1234'
\expandafter\expandafter\expandafter\@fourthoffive\csname r@#2\endcsname}%
\def\jhans@farref{\bookname\#\jhans@anchorname}% like `book.pdf#ans.1234'
\def\jhans@reftext{%
\expandafter\expandafter\expandafter\@firstoffive\csname r@#2\endcsname}%
#1~\expandafter\href\expandafter{\jhans@farref}{\jhans@reftext}%
}
\renewcommand{\nearbydefinition}[1]{\bookreference{Definition}{#1}}
\renewcommand{\nearbyfigure}[1]{\bookreference{Figure}{#1}}
\renewcommand{\nearbylemma}[1]{\bookreference{Lemma}{#1}}
\renewcommand{\nearbyexample}[1]{\bookreference{Example}{#1}}
\renewcommand{\nearbycounterexample}[1]{\bookreference{Counterexample}{#1}}
\renewcommand{\nearbytheorem}[1]{\bookreference{Theorem}{#1}}
\renewcommand{\nearbycorollary}[1]{\bookreference{Corollary}{#1}}
\renewcommand{\nearbyexercise}[1]{\bookreference{Exercise}{#1}}
\renewcommand{\nearbyremark}[1]{\bookreference{Remark}{#1}}
\renewcommand{\nearbynotice}[1]{\bookreference{Notice}{#1}}
\renewcommand{\nearbynote}[1]{\bookreference{Note}{#1}}
\fi
% PAGE LAYOUT
%
% CHAPTER and SUBSECTION commands
% \renewcommand{\chapter}{\secdef\chapcmda\chapcmdb}
% \newcommand{\chapcmda}[2][]{%
% \addcontentsline{toc}{chapter}{#1}%
% \chapheader{#1}}
% \newcommand{\chapcmdb}[1]{\chapheader{#1}}
% \newcommand{\chapheader}[1]{% \end{answerlist}
% \clearemptydoublepage\thispagestyle{empty} %
% \vspace*{4ex}
% {\centering{\LARGE\bfseries #1}}%
% \vspace{-2ex plus1ex}%
% % \begin{answerlist}\item[]
% }
% \renewcommand{\section}{\@startsection%
% {section}{1}{0em}{-10ex plus1ex minus2ex}{4ex}%
% {\usefont{T1}{fvs}{b}{n}\Large}}
\renewcommand{\section}{\vspace{0ex plus 14ex minus 14ex}\@startsection%
{section}{1}{0em}{-20ex plus10ex minus2ex}{4ex}%
{\usefont{T1}{fvs}{b}{n}\Large}}
\renewcommand{\topicsection}{\vspace{0ex plus 14ex minus 14ex}\@startsection%
{section}{1}{0em}{-10ex plus1ex minus2ex}{4ex}%
{\usefont{T1}{fvs}{b}{n}\Large \makebox[2.9em][r]{Topic: }}}
\renewcommand{\topic}[1]{\topicsection*{#1}
\stepcounter{section} % increment the section so exercises can have unique hyper reference
\renewcommand{\announcesectioninginanswerfile}{%
\sectioninginanswerfiletopicstyle}
\insidetopictrue % Handle hyperref-ing of exercise in topic way
% renew definition of exercise formatting (perhaps undone in Chapter)
\setcounter{theorem}{0} % hack to make exercise numbering correct
\renewcommand{\exercise@makelabel}{} %
% JH testing 2012-Oct-05 \renewcommand{\exercise@deflabel}[1]{\textbf{\arabic{##1}}}
\renewcommand{\exercise@deflabel}[1]{\hyperdef{exercise}{\Englishnumber{\value{chapter}}.\Roman{section}.\arabic{subsection}.\Currentlabel}{}\hyperref{./jhanswer.pdf}{ans}{\Englishnumber{\value{chapter}}.\Roman{section}.\arabic{subsection}.\Currentlabel}{\textbf{\Currentlabel}}%
% \typeout{!!! in Topic next exercise defed \Englishnumber{\value{chapter}}.\Roman{section}.\arabic{subsection}.\Currentlabel !!!!}
}
\renewcommand{\ansparams}{{\Currentlabel}}
\thispagestyle{empty}
\gdef\sectioningname{#1}%
\markright{Topic: #1}
\addcontentsline{toc}{section}{Topic: #1}
% \vspace*{15pt}\noindent\fancyfont{Topic}\par
% \vspace*{10pt}\noindent{\Large\bfseries #1}\vspace{20pt}
% \par\@afterindentfalse\nobreak
% \typeout{+++++++++ value of the chapter section subsection is \thechapter.\thesection +++++++}
}
%
% \renewcommand{\subsection}{\secdef\anssubseccmda\anssubseccmdb}
% \newcommand{\anssubseccmda}[2][?]{%
% %\end{answerlist}
% \addcontentsline{toc}{subsection}{#1}%
% \anssubsecheader{#2}}
% \newcommand{\anssubseccmdb}[1]{\anssubsecheader{#1}}
% \newcommand{\anssubsecheader}[1]{% \end{answerlist}%
% \vspace{4ex plus1ex minus.5ex}\pagebreak[3]\vspace*{1ex plus1ex minus.25ex}%
% {\flushleft\large\bfseries #1}%
% \nopagebreak\vspace{1ex plus .5ex minus.5ex} % \nopagebreak\begin{answerlist}\item[]}
% \renewcommand{\section}{\secdef\seca\secb}
% \newcommand{\seca}[1]{\clearpage {\raggedright\Large\bfseries #1}}
% \newcommand{\secb}[1]{\clearpage {\raggedright\Large\bfseries #1}}
\renewcommand{\@seccntformat}[1]{\relax}
%end PAGE LAYOUT
% Table of Contents
\usepackage{tocloft}
\renewcommand{\numberline}[1]{\relax}
% Resolve References
\input{book.aux}
\endinput