authorbold.sty 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. \ProvidesPackage{authorbold}
  2. \RequirePackage{etoolbox} % Ensure etoolbox is loaded for toggle commands
  3. \newtoggle{boldauthor} % Define a toggle for controlling bolding
  4. \togglefalse{boldauthor}
  5. \def\makenamesetup{%
  6. \def\bibnamedelima{~}%
  7. \def\bibnamedelimb{ }%
  8. \def\bibnamedelimc{ }%
  9. \def\bibnamedelimd{ }%
  10. \def\bibnamedelimi{ }%
  11. \def\bibinitperiod{.}%
  12. \def\bibinitdelim{~}%
  13. \def\bibinithyphendelim{.-}}
  14. \newcommand*{\makename}[2]{\begingroup\makenamesetup\xdef#1{#2}\endgroup}
  15. \newcommand*{\boldname}[3]{%
  16. \def\lastname{#1}%
  17. \def\firstname{#2}%
  18. \def\firstinit{#3}}
  19. \boldname{}{}{}
  20. % Patch new definitions
  21. \renewcommand{\mkbibnamegiven}[1]{%
  22. \ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
  23. {\iftoggle{boldauthor}{\textbf{#1}}{#1}}{#1}%
  24. }
  25. \renewcommand{\mkbibnamefamily}[1]{%
  26. \ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
  27. {\iftoggle{boldauthor}{\textbf{#1}}{#1}}{#1}%
  28. }
  29. \edef\dothesourcemap{
  30. \noexpand\DeclareSourcemap{
  31. \noexpand\maps[datatype=bibtex]{
  32. \noexpand\map{
  33. \noexpand\pertype{article}
  34. \noexpand\step[fieldsource=author, match=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
  35. \noexpand\step[fieldset=keywords, fieldvalue={mine_other}, append]
  36. }
  37. \noexpand\map{
  38. \noexpand\pertype{inproceedings}
  39. \noexpand\step[fieldsource=author, match=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
  40. \noexpand\step[fieldset=keywords, fieldvalue={mine_other}, append]
  41. }
  42. \noexpand\map{
  43. \noexpand\pertype{article}
  44. \noexpand\step[fieldsource=author, match=\noexpand\regexp{.*\thesisnameregex.*}, final]
  45. \noexpand\step[fieldsource=author, notmatch=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
  46. \noexpand\step[fieldset=keywords, fieldvalue={mine}, append]
  47. }
  48. \noexpand\map{
  49. \noexpand\pertype{inproceedings}
  50. \noexpand\step[fieldsource=author, match=\noexpand\regexp{.*\thesisnameregex.*}, final]
  51. \noexpand\step[fieldsource=author, notmatch=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
  52. \noexpand\step[fieldset=keywords, fieldvalue={mine}, append]
  53. }
  54. }
  55. }
  56. }
  57. \dothesourcemap
  58. % Commands to enable or disable bolding as needed in the document
  59. \newcommand{\enableboldauthor}{\toggletrue{boldauthor}}
  60. \newcommand{\disableboldauthor}{\togglefalse{boldauthor}}
  61. % You can comment in the following code to also make the labels bold
  62. % \DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{\ifkeyword{mine}{\mkbibbold{#1}}{#1}}}
  63. % \DeclareFieldFormat{boldmine}{\ifkeyword{mine}{\mkbibbold{#1}}{#1}}
  64. % \makeatletter
  65. % \renewbibmacro*{cite:comp:comp}{%
  66. % \ifboolexpr{
  67. % ( test {\iffieldundef{labelprefix}} and test {\ifundef\cbx@lastprefix} )
  68. % or
  69. % test {\iffieldequals{labelprefix}{\cbx@lastprefix}}
  70. % }
  71. % {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}}
  72. % {\savefield{entrykey}{\cbx@lastkey}%
  73. % \savefield{labelnumber}{\cbx@lastnumber}%
  74. % \addtocounter{cbx@tempcnta}{1}}
  75. % {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}-1}
  76. % {}
  77. % {\usebibmacro{cite:dump}%
  78. % \ifnumgreater{\value{cbx@tempcntb}}{-1}
  79. % {\multicitedelim}
  80. % {}%
  81. % \printtext[bibhyperref]{%
  82. % \printtext[boldmine]{%
  83. % \printfield{labelprefix}%
  84. % \printfield{labelnumber}}}}}}
  85. % {\usebibmacro{cite:comp:end}}%
  86. % \setcounter{cbx@tempcntb}{\thefield{labelnumber}}%
  87. % \savefield{labelprefix}{\cbx@lastprefix}}
  88. % \renewbibmacro*{cite:comp:end}{%
  89. % \usebibmacro{cite:dump}%
  90. % \ifnumgreater{\value{cbx@tempcntb}}{-1}
  91. % {\multicitedelim}
  92. % {}%
  93. % \printtext[bibhyperref]{%
  94. % \printtext[boldmine]{%
  95. % \printfield{labelprefix}%
  96. % \printfield{labelnumber}}}}
  97. % \renewbibmacro*{cite:comp:inset}{%
  98. % \usebibmacro{cite:dump}%
  99. % \ifnumgreater{\value{cbx@tempcntb}}{-1}
  100. % {\multicitedelim}
  101. % {}%
  102. % \printtext[bibhyperref]{%
  103. % \printtext[boldmine]{%
  104. % \printfield{labelprefix}%
  105. % \printfield{labelnumber}%
  106. % \printfield{entrysetcount}}}%
  107. % \setcounter{cbx@tempcntb}{-1}}
  108. % \renewbibmacro*{cite:comp:shand}{%
  109. % \usebibmacro{cite:dump}%
  110. % \ifnumgreater{\value{cbx@tempcntb}}{-1}
  111. % {\multicitedelim}
  112. % {}%
  113. % \printtext[bibhyperref]{\printtext[boldmine]{\printfield{shorthand}}}%
  114. % \setcounter{cbx@tempcntb}{-1}}
  115. % \newbibmacro*{cite:dump}{%
  116. % \ifnumgreater{\value{cbx@tempcnta}}{0}
  117. % {\ifnumgreater{\value{cbx@tempcnta}}{1}
  118. % {\bibrangedash}
  119. % {\multicitedelim}%
  120. % \bibhyperref[\cbx@lastkey]{\printtext[boldmine]{%
  121. % \ifdef\cbx@lastprefix
  122. % {\printtext[labelprefix]{\cbx@lastprefix}}
  123. % {}%
  124. % \printtext[labelnumber]{\cbx@lastnumber}}}}
  125. % {}%
  126. % \setcounter{cbx@tempcnta}{0}%
  127. % \global\undef\cbx@lastprefix}
  128. % \makeatother