File tree 6 files changed +16
-24
lines changed
6 files changed +16
-24
lines changed Original file line number Diff line number Diff line change 27
27
\newcommand {\htmltag }[1]{\texttt {{\textless }{#1}{\textgreater } }}
28
28
29
29
% Chapters, sections, and appendices with labels.
30
- \newcommand {\chaplbl }[2]{\chapter {#1 }\label {#2 }}
31
- \newcommand {\seclbl }[2]{\section {#1 }\label {#2 }}
32
30
\newcommand {\appref }[1]{Appendix~\ref {#1 }}
33
31
\newcommand {\chapref }[1]{Chapter~\ref {#1 }}
34
32
\newcommand {\figref }[1]{Figure~\ref {#1 }}
35
33
\newcommand {\secref }[1]{Section~\ref {#1 }}
36
34
\newcommand {\tblref }[1]{Table~\ref {#1 }}
37
35
36
+ % Always put \label after \caption.
37
+ \newcommand {\caplbl }[2]{\caption {{#1}\label {#2 }}}
38
+
38
39
% Image figures.
39
40
\newcommand {\figimg }[3]{\begin {figure }%
40
41
\centering %
41
42
\includegraphics [width=\textwidth ]{#1}%
42
- \caption {#2}%
43
- \label {#3 }%
43
+ \caplbl {#2}{#3}%
44
44
\end {figure }}
45
45
46
46
% PDF figures.
47
47
\newcommand {\figpdf }[3]{\begin {figure }%
48
48
\centering %
49
49
\includegraphics [scale=0.6]{#1}%
50
- \caption {#2}%
51
- \label {#3 }%
50
+ \caplbl {#2}{#3}%
52
51
\end {figure }}
53
52
54
53
% PDF figures forcing location.
55
54
\newcommand {\figpdfhere }[3]{\begin {figure }[H]%
56
55
\centering %
57
56
\includegraphics [scale=0.6]{#1}%
58
- \caption {#2}%
59
- \label {#3 }%
57
+ \caplbl {#2}{#3}%
60
58
\end {figure }}
61
59
62
60
% Exercise headings.
Original file line number Diff line number Diff line change @@ -51,8 +51,7 @@ \section{Text}\label{s:htmlcss-text}
51
51
Copyright & \texttt {\& copy; } & © \\
52
52
Plus/minus & \texttt {\& plusmn; } & ± \\
53
53
Micro & \texttt {\& micro; } & µ \\
54
- \caption {HTML Escapes}
55
- \label {t:htmlcss-escapes }
54
+ \caplbl {HTML Escapes}{t:htmlcss-escapes}
56
55
\end {longtable }
57
56
58
57
The first two are self-explanatory,
Original file line number Diff line number Diff line change @@ -19,8 +19,7 @@ \section{Equality}\label{s:legacy-equality}
19
19
empty array plus empty object & \texttt {[]\ +\ \{\} } & \texttt {\{\} } (empty object) \\
20
20
empty object plus empty array & \texttt {\{\}\ +\ [] } & \texttt {0 } (number zero) \\
21
21
empty object plus empty object & \texttt {\{\}\ +\ \{\} } & \texttt {NaN } (not a number) \\
22
- \caption {Surprising Results}
23
- \label {t:legacy-surprises }
22
+ \caplbl {Surprising Results}{t:legacy-surprises}
24
23
\end {longtable }
25
24
26
25
In order to understand this, we need to know several things
Original file line number Diff line number Diff line change 113
113
\newcommand {\htmltag }[1]{{\textless }{#1}{\textgreater }}
114
114
115
115
% Chapters, sections, and appendices with labels.
116
- \newcommand {\chaplbl }[2]{\chapter {#1 }\label {#2 }}
117
- \newcommand {\seclbl }[2]{\section {#1 }\label {#2 }}
118
116
\newcommand {\appref }[1]{Appendix~\ref {#1 }}
119
117
\newcommand {\chapref }[1]{Chapter~\ref {#1 }}
120
118
\newcommand {\figref }[1]{Figure~\ref {#1 }}
121
119
\newcommand {\secref }[1]{Section~\ref {#1 }}
122
120
\newcommand {\tblref }[1]{Table~\ref {#1 }}
123
121
122
+ % Always put \label after \caption.
123
+ \newcommand {\caplbl }[2]{\caption {{#1}\label {#2 }}}
124
+
124
125
% Image figures.
125
126
\newcommand {\figimg }[3]{\begin {figure }%
126
127
\centering %
127
128
\includegraphics [width=\textwidth ]{#1}%
128
- \caption {#2}%
129
- \label {#3 }%
129
+ \caplbl {#2}{#3}%
130
130
\end {figure }}
131
131
132
132
% PDF figures.
133
133
\newcommand {\figpdf }[3]{\begin {figure }%
134
134
\centering %
135
135
\includegraphics [scale=0.6]{#1}%
136
- \caption {#2}%
137
- \label {#3 }%
136
+ \caplbl {#2}{#3}%
138
137
\end {figure }}
139
138
140
139
% PDF figures forcing location.
141
140
\newcommand {\figpdfhere }[3]{\begin {figure }[H]%
142
141
\centering %
143
142
\includegraphics [scale=0.6]{#1}%
144
- \caption {#2}%
145
- \label {#3 }%
143
+ \caplbl {#2}{#3}%
146
144
\end {figure }}
147
145
148
146
% Exercise headings.
Original file line number Diff line number Diff line change @@ -113,8 +113,7 @@ \chapter{Regular Expressions}\label{s:regexp}
113
113
& yes & contains either `` Dr'' or `` Prof'' followed by literal '.'
114
114
\\
115
115
116
- \caption {Regular Expression Matches}
117
- \label {t:regexp-examples }
116
+ \caplbl {Regular Expression Matches}{t:regexp-examples}
118
117
\end {longtable }
119
118
120
119
This is a lot to digest,
Original file line number Diff line number Diff line change @@ -104,8 +104,7 @@ \section{HTTP}\label{s:server-http}
104
104
500 & Internal Server Error & A server error occurred while handling the request \\
105
105
601 & Connection Timed Out & The server did not respond before the connection timed out
106
106
\end {tabular }
107
- \caption {HTTP Status Codes}
108
- \label {t:server-codes }
107
+ \caplbl {HTTP Status Codes}{t:server-codes}
109
108
\end {table }
110
109
111
110
One final thing we need to understand is the structure and interpretation of URLs.
You can’t perform that action at this time.
0 commit comments