Переглянути джерело

authorbold... hope it works :D

Daniel Gruss 1 рік тому
батько
коміт
59fe542f13
3 змінених файлів з 181 додано та 10 видалено
  1. 147 0
      authorbold.sty
  2. 26 9
      main.tex.php
  3. 8 1
      thesiscomposer.php

+ 147 - 0
authorbold.sty

@@ -0,0 +1,147 @@
+\ProvidesPackage{authorbold}
+
+\RequirePackage{etoolbox} % Ensure etoolbox is loaded for toggle commands
+
+\newtoggle{boldauthor} % Define a toggle for controlling bolding
+\togglefalse{boldauthor}
+
+\def\makenamesetup{%
+  \def\bibnamedelima{~}%
+  \def\bibnamedelimb{ }%
+  \def\bibnamedelimc{ }%
+  \def\bibnamedelimd{ }%
+  \def\bibnamedelimi{ }%
+  \def\bibinitperiod{.}%
+  \def\bibinitdelim{~}%
+  \def\bibinithyphendelim{.-}}    
+\newcommand*{\makename}[2]{\begingroup\makenamesetup\xdef#1{#2}\endgroup}
+
+\newcommand*{\boldname}[3]{%
+  \def\lastname{#1}%
+  \def\firstname{#2}%
+  \def\firstinit{#3}}
+\boldname{}{}{}
+
+% Patch new definitions
+\renewcommand{\mkbibnamegiven}[1]{%
+  \ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
+  {\iftoggle{boldauthor}{\textbf{#1}}{#1}}{#1}%
+}
+
+\renewcommand{\mkbibnamefamily}[1]{%
+  \ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
+  {\iftoggle{boldauthor}{\textbf{#1}}{#1}}{#1}%
+}
+
+\edef\dothesourcemap{
+  \noexpand\DeclareSourcemap{
+    \noexpand\maps[datatype=bibtex]{
+      \noexpand\map{
+        \noexpand\pertype{article}
+        \noexpand\step[fieldsource=author, match=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
+        \noexpand\step[fieldset=keywords, fieldvalue={mine_other}, append]
+      }
+      \noexpand\map{
+        \noexpand\pertype{inproceedings}
+        \noexpand\step[fieldsource=author, match=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
+        \noexpand\step[fieldset=keywords, fieldvalue={mine_other}, append]
+      }
+      \noexpand\map{
+        \noexpand\pertype{article}
+        \noexpand\step[fieldsource=author, match=\noexpand\regexp{.*\thesisnameregex.*}, final]
+        \noexpand\step[fieldsource=author, notmatch=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
+        \noexpand\step[fieldset=keywords, fieldvalue={mine}, append]
+      }
+      \noexpand\map{
+        \noexpand\pertype{inproceedings}
+        \noexpand\step[fieldsource=author, match=\noexpand\regexp{.*\thesisnameregex.*}, final]
+        \noexpand\step[fieldsource=author, notmatch=\noexpand\regexp{.* and .*\thesisnameregex.*}, final]
+        \noexpand\step[fieldset=keywords, fieldvalue={mine}, append]
+      }
+    }
+  }
+}
+\dothesourcemap
+
+
+% Commands to enable or disable bolding as needed in the document
+\newcommand{\enableboldauthor}{\toggletrue{boldauthor}}
+\newcommand{\disableboldauthor}{\togglefalse{boldauthor}}
+
+% You can comment in the following code to also make the labels bold
+
+% \DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{\ifkeyword{mine}{\mkbibbold{#1}}{#1}}}
+% \DeclareFieldFormat{boldmine}{\ifkeyword{mine}{\mkbibbold{#1}}{#1}}
+
+% \makeatletter
+% \renewbibmacro*{cite:comp:comp}{%
+%   \ifboolexpr{
+%     ( test {\iffieldundef{labelprefix}} and test {\ifundef\cbx@lastprefix} )
+%     or
+%     test {\iffieldequals{labelprefix}{\cbx@lastprefix}}
+%   }
+%     {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}}
+%        {\savefield{entrykey}{\cbx@lastkey}%
+%         \savefield{labelnumber}{\cbx@lastnumber}%
+%         \addtocounter{cbx@tempcnta}{1}}
+%        {\ifnumequal{\thefield{labelnumber}}{\value{cbx@tempcntb}-1}
+%           {}
+%           {\usebibmacro{cite:dump}%
+%            \ifnumgreater{\value{cbx@tempcntb}}{-1}
+%              {\multicitedelim}
+%              {}%
+%              \printtext[bibhyperref]{%
+%              \printtext[boldmine]{%
+%              \printfield{labelprefix}%
+%              \printfield{labelnumber}}}}}}
+%     {\usebibmacro{cite:comp:end}}%
+%   \setcounter{cbx@tempcntb}{\thefield{labelnumber}}%
+%   \savefield{labelprefix}{\cbx@lastprefix}}
+
+% \renewbibmacro*{cite:comp:end}{%
+% \usebibmacro{cite:dump}%
+% \ifnumgreater{\value{cbx@tempcntb}}{-1}
+%   {\multicitedelim}
+%   {}%
+% \printtext[bibhyperref]{%
+% \printtext[boldmine]{%
+%   \printfield{labelprefix}%
+%   \printfield{labelnumber}}}}
+
+
+% \renewbibmacro*{cite:comp:inset}{%
+% \usebibmacro{cite:dump}%
+% \ifnumgreater{\value{cbx@tempcntb}}{-1}
+%   {\multicitedelim}
+%   {}%
+% \printtext[bibhyperref]{%
+% \printtext[boldmine]{%
+%   \printfield{labelprefix}%
+%   \printfield{labelnumber}%
+%   \printfield{entrysetcount}}}%
+% \setcounter{cbx@tempcntb}{-1}}
+
+% \renewbibmacro*{cite:comp:shand}{%
+% \usebibmacro{cite:dump}%
+% \ifnumgreater{\value{cbx@tempcntb}}{-1}
+%   {\multicitedelim}
+%   {}%
+% \printtext[bibhyperref]{\printtext[boldmine]{\printfield{shorthand}}}%
+% \setcounter{cbx@tempcntb}{-1}}
+
+% \newbibmacro*{cite:dump}{%
+%   \ifnumgreater{\value{cbx@tempcnta}}{0}
+%     {\ifnumgreater{\value{cbx@tempcnta}}{1}
+%        {\bibrangedash}
+%        {\multicitedelim}%
+%      \bibhyperref[\cbx@lastkey]{\printtext[boldmine]{%
+%        \ifdef\cbx@lastprefix
+%          {\printtext[labelprefix]{\cbx@lastprefix}}
+%          {}%
+%        \printtext[labelnumber]{\cbx@lastnumber}}}}
+%     {}%
+%   \setcounter{cbx@tempcnta}{0}%
+%   \global\undef\cbx@lastprefix}
+
+% \makeatother
+

+ 26 - 9
main.tex.php

@@ -15,6 +15,16 @@
 \fi
 
 \usepackage{tugraz_defaults}
+<?php
+echo '
+
+
+\newcommand{\thesisnameregex}{(('.$thesis_familyname.',\noexpand\s+'.$thesis_firstname.')|('.$thesis_firstname.'\noexpand\s+'.$thesis_familyname.'))}
+\usepackage{authorbold}
+\boldname{'.$thesis_familyname.'}{'.$thesis_firstname.'}{'.$thesis_initial.'}
+';
+?>
+
 \addbibresource{main.bib}
 % TODO: if you have unused bib files lying around, some of theses might be incorrectly added:
 <?php 
@@ -145,17 +155,24 @@ During my thesis, I contributed to <?php echo $num_publications ?> publications
 
 \newrefcontext[sorting=ydnt]
 
-<?php 
-if (isset($options['--cv']))
-{
-echo '\nocite{CV:*}';
-}
-?>
-
 <?php echo $sloppy_begin; ?>
-\printbibliography[title={Publications in this Thesis}, type=inproceedings, heading=subbibliography, keyword={mine}]
 
-\printbibliography[title={Other Contributions}, type=inproceedings, heading=subbibliography, keyword={mine_other}]
+\nocite{*}
+
+\defbibenvironment{mypubs}
+  {\begin{enumerate}[]
+      \setlength{\leftmargin}{\bibhang}%
+      \setlength{\itemindent}{0pt}%
+      \setlength{\itemsep}{\bibitemsep}%
+      \setlength{\parsep}{\bibparsep}}
+  {\end{enumerate}}
+  {\item}
+
+\enableboldauthor
+\printbibliography[env=mypubs,title={Publications in this Thesis}, type=inproceedings, heading=subbibliography, keyword={mine}]
+
+\printbibliography[env=mypubs,check=mineotheronly, title={Other Contributions}, type=inproceedings, heading=subbibliography]
+\disableboldauthor
 <?php echo $sloppy_end; ?>
 
 \end{refsection}

+ 8 - 1
thesiscomposer.php

@@ -485,6 +485,7 @@ TODO
 
 
 \\newpage
+\\newrefcontext[sorting=ydnt]
 \begin{center}
 {\Large \bfseries
 
@@ -617,6 +618,9 @@ END;
       $tex = preg_replace("/\n\s*\\\\authorrunning\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
       $tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
       $tex = preg_replace("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\titlespacing\*?(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\titlerunning\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\orcid\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
       $tex = preg_replace("/\n\s*\\\\tikzexternalize/i","",$tex);
       $tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
 
@@ -804,7 +808,10 @@ END;
   $thesis_type = user_prompt("Enter Thesis Type ","PhD Thesis");
   $thesis_title = user_prompt("Enter Thesis Title ","Security of TODO");
   $thesis_part1_title = user_prompt("Enter Introductory Part Title ","Introduction to the Security of TODO");
-  $thesis_author = user_prompt("Enter Your Name ","Harry Potter");
+  $thesis_familyname = user_prompt("Enter Your Family Name ","Potter");
+  $thesis_firstname = user_prompt("Enter Your First Name(s) ","Harry");
+  $thesis_initial = $thesis_firstname[0] . ".";
+  $thesis_author = $thesis_firstname . " " . $thesis_familyname;
   $thesis_date = user_prompt("Enter Prospective Defense Month", "July 1998");
   $thesis_institute = user_prompt("Enter Your Institute","Institute for Applied Information Processing and Communications");
   $thesis_assessors = user_prompt("Enter Names of your Assessors (comma-separated)","Severus Snape, Minerva McGonagall");