summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex2bibitem/biblatex2bibitem.sty
blob: 72b5cde68ab88ee48e4125e106cdc2c9898cb88a (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
% A workaround to convert biblatex-generated bibliography to bibitems
%
% (c) Nikolai Avdeev aka @nickkolok, and @odomanov
%
% See also https://github.com/odomanov/biblatex-gost/issues/20
%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% https://ctan.org/license/lppl1.3c
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{biblatex2bibitem}
  [2022/01/17 v0.2.2 LaTeX package to convert biblatex-generated bibliography to bibitem commands]

\RequirePackage{biblatex}

\newcommand{\printgeneratedbibitemseparator}{\{\}\\}

\newcommand{\print@begin@thebibliography}{\textbackslash begin\{thebibliography\}\{99\}}
\newcommand{\print@end@thebibliography  }{\textbackslash   end\{thebibliography\}      }

\newcommand{\print@bibitem@command}{\textbackslash bibitem}


\defbibenvironment{bibitembibliography}
  {
   % Page numbers and page headings are not wanted when copying
   \thispagestyle{empty}
   \pagestyle{empty}
   \hyphenpenalty=10000
   \exhyphenpenalty=10000
   \raggedright
   % Ignore curly braces when putting dots to avoid
   % \emph{Banach) \emph{S.}.
   \sfcode`\{=\z@
   \sfcode`\}=\z@
   %
   \renewcommand*{\&}{\textbackslash \symbol{38}}%
   \ifcsname mkbibsc\endcsname% Sometimes it is not defined
    \renewcommand*{\mkbibsc}[1]{\textbackslash textsc\{##1\}}%
   \fi%
   \renewcommand*{\texttt}[1]{\textbackslash texttt\{##1\}}%
   \renewcommand*{\textit}[1]{\textbackslash textit\{##1\}}%
   \renewcommand*{\textbf}[1]{\textbackslash textbf\{##1\}}%
   \renewcommand*{\textsc}[1]{\textbackslash textsc\{##1\}}%
   \renewcommand*{\emph}[1]{\textbackslash emph\{##1\}}%
   %
   \providecommand*{\nolinkurl}{\url}
   \renewcommand*{\nolinkurl}[1]{\textbackslash nolinkurl \{##1\}}%
   \renewcommand*{\url}[1]{\textbackslash url \{##1\}}%
   %
   \ifcsname href\endcsname% Sometimes it is not defined
    \renewcommand*{\href}[2]{\textbackslash href \{##1\} \{##2\}}%
   \fi
   %
   \ifcsname hyperlink\endcsname% Sometimes it is not defined
    \renewcommand*{\hyperlink}[2]{\textbackslash hyperlink \{##1\} \{##2\}}%
   \fi
   %
   \renewcommand*{\mkbibemph}[1]{\textbackslash emph\{##1\}}%
   \renewcommand*{\mkbibitalic}[1]{\textbackslash textit\{##1\}}%
   \renewcommand*{\mkbibbold}[1]{\textbackslash textbf\{##1\}}%
   %\DeclareFieldFormat{titlecase}{\texttt{\utffriendlydetokenize{#1}}}
   \print@begin@thebibliography
   \list{}{}}
  {\endlist
   \print@end@thebibliography
   \thispagestyle{empty}
   \pagestyle{empty}
  }
  {\item\printgeneratedbibitemseparator\print@bibitem@command\{\printfield{entrykey}\}\\}

\newcommand{\utffriendlydetokenize}[1]{%
\scantokens{%
\catcode`\_=12%
\catcode`\^=12%
\catcode`\{=12%
\catcode`\}=12%
\catcode`\&=12%
\catcode`\$=12%
\catcode`\#=12%
\catcode`\~=12%
\catcode`\\=12%
#1%
}%
}


\newcommand{\ignorespacesaftertitlecase}{\leavevmode\unskip}

\newcommand{\printbibitembibliography}{
	\DeclareFieldFormat{titlecase}{\utffriendlydetokenize{##1}\ignorespacesaftertitlecase}
	%\DeclareDelimFormat[bib]{nametitledelim}{\newline\bibsentence}
	\printbibliography[env=bibitembibliography]
}



\endinput
%%
%% End of file `biblatex2bibitem.sty'.