Modifying citation command












0















I am using the code provided in this question regarding coloring citations.



The problem is that I don't know how to make (redefine) the cite command to add parentheses around the year










share|improve this question





























    0















    I am using the code provided in this question regarding coloring citations.



    The problem is that I don't know how to make (redefine) the cite command to add parentheses around the year










    share|improve this question



























      0












      0








      0








      I am using the code provided in this question regarding coloring citations.



      The problem is that I don't know how to make (redefine) the cite command to add parentheses around the year










      share|improve this question
















      I am using the code provided in this question regarding coloring citations.



      The problem is that I don't know how to make (redefine) the cite command to add parentheses around the year







      biblatex






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 25 at 11:52









      moewe

      92.6k10115351




      92.6k10115351










      asked Feb 25 at 11:06









      YorgosYorgos

      1,32511525




      1,32511525






















          1 Answer
          1






          active

          oldest

          votes


















          3














          Here is a simple hack, defining a colortextcite command, based on textcite:



          documentclass[presentation]{beamer}

          usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}

          addbibresource{references.bib}

          DeclareCiteCommand{cite}
          {color{red}usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          DeclareCiteCommand{parencite}[mkcolorbibparens]
          {usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          makeatletter
          newrobustcmd{mkcolorbibparens}[1]{%
          begingroup
          color{red}%
          blx@blxinit
          blx@setsfcodes
          bibopenparen#1bibcloseparen
          endgroup}
          makeatother

          usepackage{filecontents}
          begin{filecontents}{references.bib}
          @Book{bartolini-mair-1990,
          author = {Bartolini, Stefano AND Mair, Peter},
          title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
          publisher = {Cambridge University Press},
          year = 1990,
          address = {Cambridge},
          }
          end{filecontents}

          newcommand{colortextcite}[1]{textcolor{red}{textcite{#1}}}

          begin{document}

          begin{frame}
          Text cite{bartolini-mair-1990} text

          Text parencite{bartolini-mair-1990} text

          Text colortextcite{bartolini-mair-1990} text
          end{frame}

          begin{frame}
          printbibliography
          end{frame}

          end{document}


          enter image description here






          share|improve this answer
























          • i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

            – Yorgos
            Feb 25 at 12:10











          • [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

            – Bernard
            Feb 25 at 12:24













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476576%2fmodifying-citation-command%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Here is a simple hack, defining a colortextcite command, based on textcite:



          documentclass[presentation]{beamer}

          usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}

          addbibresource{references.bib}

          DeclareCiteCommand{cite}
          {color{red}usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          DeclareCiteCommand{parencite}[mkcolorbibparens]
          {usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          makeatletter
          newrobustcmd{mkcolorbibparens}[1]{%
          begingroup
          color{red}%
          blx@blxinit
          blx@setsfcodes
          bibopenparen#1bibcloseparen
          endgroup}
          makeatother

          usepackage{filecontents}
          begin{filecontents}{references.bib}
          @Book{bartolini-mair-1990,
          author = {Bartolini, Stefano AND Mair, Peter},
          title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
          publisher = {Cambridge University Press},
          year = 1990,
          address = {Cambridge},
          }
          end{filecontents}

          newcommand{colortextcite}[1]{textcolor{red}{textcite{#1}}}

          begin{document}

          begin{frame}
          Text cite{bartolini-mair-1990} text

          Text parencite{bartolini-mair-1990} text

          Text colortextcite{bartolini-mair-1990} text
          end{frame}

          begin{frame}
          printbibliography
          end{frame}

          end{document}


          enter image description here






          share|improve this answer
























          • i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

            – Yorgos
            Feb 25 at 12:10











          • [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

            – Bernard
            Feb 25 at 12:24


















          3














          Here is a simple hack, defining a colortextcite command, based on textcite:



          documentclass[presentation]{beamer}

          usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}

          addbibresource{references.bib}

          DeclareCiteCommand{cite}
          {color{red}usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          DeclareCiteCommand{parencite}[mkcolorbibparens]
          {usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          makeatletter
          newrobustcmd{mkcolorbibparens}[1]{%
          begingroup
          color{red}%
          blx@blxinit
          blx@setsfcodes
          bibopenparen#1bibcloseparen
          endgroup}
          makeatother

          usepackage{filecontents}
          begin{filecontents}{references.bib}
          @Book{bartolini-mair-1990,
          author = {Bartolini, Stefano AND Mair, Peter},
          title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
          publisher = {Cambridge University Press},
          year = 1990,
          address = {Cambridge},
          }
          end{filecontents}

          newcommand{colortextcite}[1]{textcolor{red}{textcite{#1}}}

          begin{document}

          begin{frame}
          Text cite{bartolini-mair-1990} text

          Text parencite{bartolini-mair-1990} text

          Text colortextcite{bartolini-mair-1990} text
          end{frame}

          begin{frame}
          printbibliography
          end{frame}

          end{document}


          enter image description here






          share|improve this answer
























          • i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

            – Yorgos
            Feb 25 at 12:10











          • [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

            – Bernard
            Feb 25 at 12:24
















          3












          3








          3







          Here is a simple hack, defining a colortextcite command, based on textcite:



          documentclass[presentation]{beamer}

          usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}

          addbibresource{references.bib}

          DeclareCiteCommand{cite}
          {color{red}usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          DeclareCiteCommand{parencite}[mkcolorbibparens]
          {usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          makeatletter
          newrobustcmd{mkcolorbibparens}[1]{%
          begingroup
          color{red}%
          blx@blxinit
          blx@setsfcodes
          bibopenparen#1bibcloseparen
          endgroup}
          makeatother

          usepackage{filecontents}
          begin{filecontents}{references.bib}
          @Book{bartolini-mair-1990,
          author = {Bartolini, Stefano AND Mair, Peter},
          title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
          publisher = {Cambridge University Press},
          year = 1990,
          address = {Cambridge},
          }
          end{filecontents}

          newcommand{colortextcite}[1]{textcolor{red}{textcite{#1}}}

          begin{document}

          begin{frame}
          Text cite{bartolini-mair-1990} text

          Text parencite{bartolini-mair-1990} text

          Text colortextcite{bartolini-mair-1990} text
          end{frame}

          begin{frame}
          printbibliography
          end{frame}

          end{document}


          enter image description here






          share|improve this answer













          Here is a simple hack, defining a colortextcite command, based on textcite:



          documentclass[presentation]{beamer}

          usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}

          addbibresource{references.bib}

          DeclareCiteCommand{cite}
          {color{red}usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          DeclareCiteCommand{parencite}[mkcolorbibparens]
          {usebibmacro{prenote}}%
          {usebibmacro{citeindex}%
          usebibmacro{cite}}
          {multicitedelim}
          {usebibmacro{postnote}}

          makeatletter
          newrobustcmd{mkcolorbibparens}[1]{%
          begingroup
          color{red}%
          blx@blxinit
          blx@setsfcodes
          bibopenparen#1bibcloseparen
          endgroup}
          makeatother

          usepackage{filecontents}
          begin{filecontents}{references.bib}
          @Book{bartolini-mair-1990,
          author = {Bartolini, Stefano AND Mair, Peter},
          title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
          publisher = {Cambridge University Press},
          year = 1990,
          address = {Cambridge},
          }
          end{filecontents}

          newcommand{colortextcite}[1]{textcolor{red}{textcite{#1}}}

          begin{document}

          begin{frame}
          Text cite{bartolini-mair-1990} text

          Text parencite{bartolini-mair-1990} text

          Text colortextcite{bartolini-mair-1990} text
          end{frame}

          begin{frame}
          printbibliography
          end{frame}

          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 25 at 11:50









          BernardBernard

          172k776204




          172k776204













          • i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

            – Yorgos
            Feb 25 at 12:10











          • [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

            – Bernard
            Feb 25 at 12:24





















          • i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

            – Yorgos
            Feb 25 at 12:10











          • [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

            – Bernard
            Feb 25 at 12:24



















          i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

          – Yorgos
          Feb 25 at 12:10





          i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1

          – Yorgos
          Feb 25 at 12:10













          [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

          – Bernard
          Feb 25 at 12:24







          [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org.

          – Bernard
          Feb 25 at 12:24




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476576%2fmodifying-citation-command%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?