File: tthntbib.sty

package info (click to toggle)
tth 4.08+ds-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,376 kB
  • ctags: 124
  • sloc: xml: 291; makefile: 174; sh: 168; ansic: 131
file content (74 lines) | stat: -rw-r--r-- 2,515 bytes parent folder | download | duplicates (5)
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
% Style for authoryear type of natbib citations, including double
% optional argument handling.
% Conditional to determine if we are using number style references.
%\newif\ifNAT@numbers
% Formatting of citations requires 4 arguments unlike normal latex 1
% They are number, year, author, long-author. The format is changed
% within some types of references by local redefinition prior to
% calling cite. The default natbib formats for a plain \cite 
% call when authordate are:
%\def\tthbibform#1#2#3#4{[#3 #2}
%\def\tthciteform#1#2#3#4{#3}
% and when numbers one uses argument #1
%\def\tthbibform#1#2#3#4{\ifNAT@numbers[#1\else[#3 #2\fi}
%\def\tthciteform#1#2#3#4{\ifNAT@numbers[#1\else#3, [#2\fi}
%\def\tthciteob{}\def\tthcitecb{]}
% All the above is builtin, together with setting NAT@numbers.

% \citet is a textual citation with parens only round the year
% Second optional argument is handled with a subcommand and conditional.
\def\tthpnote{}
\newcommand\tthsubcitet[2][]{\citet[#1]{#2} \egroup}
\newcommand\citet[2][]{%
\ifx #2[ \bgroup\def\tthpnote{#1\def\tthpnote{}} \tthsubcitet[\else%
 {\def\tthcitecb{]}\def\tthcitefi{,}\def\tthcitepb{],}
  \ifNAT@numbers% 
    \def\tthciteob{}
    \def\tthciteform##1##2##3##4{##3 [\tthpnote ##1}
  \else%
    \def\tthciteform##1##2##3##4{##3 [\tthpnote ##2}
  \fi%
  \cite[#1]{#2}
 }\fi}

% \citep has parens round the whole thing.
\newcommand\tthsubcitep[2][]{
\def\tthciteob{[}\def\tthcitecb{]}
 \ifNAT@numbers
  \def\tthciteform##1##2##3##4{\tthpnote\ ##1}\cite[#1]{#2}
  \egroup%
 \else
  \def\tthciteform##1##2##3##4{\tthpnote\ ##3 ##2}\cite[#1]{#2}
 \egroup%
 \fi
}
\newcommand\citep[2][]{
\ifx #2[\bgroup\def\tthpnote{#1\def\tthpnote{}} \tthsubcitep[\else{%
  \ifNAT@numbers \def\tthciteform##1##2##3##4{##1}
  \else\def\tthciteform##1##2##3##4{##3, ##2}\fi%
\def\tthciteob{[}\def\tthcitecb{]}\cite[#1]{#2}}%
\fi}

% Additional types of natbib reference.
\newcommand\citeauthor[2][]{{%\def\tthciteob{}
\def\tthcitecb{}%
 \def\tthciteform##1##2##3##4{##3}\cite[#1]{#2}}}
\newcommand\citeyear[2][]{{%\def\tthciteob{}
\def\tthcitecb{}
 \def\tthciteform##1##2##3##4{##2}\cite[#1]{#2}}}
\newcommand\citeyearpar[2][]{{\def\tthciteob{[}\def\tthcitecb{]}
 \def\tthciteform##1##2##3##4{##2}\cite[#1]{#2}}}

% bibpunct setting
\newcommand\bibpunct[7][, ]{
 \def\tthciteob{#2}\def\tthcitecb{#3}\def\tthcitepb{#4}
 \ifx#5n\NAT@numberstrue\else
  \ifx#5s\NAT@numberstrue
    \def\tthciteob{#2$^\bgroup}\def\tthcitecb{\egroup$#3}%
  \else\NAT@numbersfalse	
  \fi
 \fi
}