Custom cite command












0















I'm trying to create a custom cite command that takes in three arguments: the book/article name and the initial and final pages of the part that I'm citing. This is the code so far:



renewcommand{cite}[3]{
(vedi~ifthenelse{equal{#2}{#3}}
{parencite[pno~#2]{#1}}
{parencite[ppno~#2~hspace{-0.035cm}--hspace{-0.035cm}~#3]{#1}}hspace{0.035cm})\}


So if the input is



cite{book_1}{64}{64}


the output is



enter image description here



I'd like to modify is so that that output corresponds to the input



cite{book_1, 64}


if the initial and final cited pages are the same, and



cite{book_1, 64-65}


if they're different. Is there a way to do this?










share|improve this question























  • Why do you want to do this, rather than just use the optional arguments to the cite command? e.g. cite[p.64]{book1}

    – Seamus
    Feb 8 at 16:34
















0















I'm trying to create a custom cite command that takes in three arguments: the book/article name and the initial and final pages of the part that I'm citing. This is the code so far:



renewcommand{cite}[3]{
(vedi~ifthenelse{equal{#2}{#3}}
{parencite[pno~#2]{#1}}
{parencite[ppno~#2~hspace{-0.035cm}--hspace{-0.035cm}~#3]{#1}}hspace{0.035cm})\}


So if the input is



cite{book_1}{64}{64}


the output is



enter image description here



I'd like to modify is so that that output corresponds to the input



cite{book_1, 64}


if the initial and final cited pages are the same, and



cite{book_1, 64-65}


if they're different. Is there a way to do this?










share|improve this question























  • Why do you want to do this, rather than just use the optional arguments to the cite command? e.g. cite[p.64]{book1}

    – Seamus
    Feb 8 at 16:34














0












0








0








I'm trying to create a custom cite command that takes in three arguments: the book/article name and the initial and final pages of the part that I'm citing. This is the code so far:



renewcommand{cite}[3]{
(vedi~ifthenelse{equal{#2}{#3}}
{parencite[pno~#2]{#1}}
{parencite[ppno~#2~hspace{-0.035cm}--hspace{-0.035cm}~#3]{#1}}hspace{0.035cm})\}


So if the input is



cite{book_1}{64}{64}


the output is



enter image description here



I'd like to modify is so that that output corresponds to the input



cite{book_1, 64}


if the initial and final cited pages are the same, and



cite{book_1, 64-65}


if they're different. Is there a way to do this?










share|improve this question














I'm trying to create a custom cite command that takes in three arguments: the book/article name and the initial and final pages of the part that I'm citing. This is the code so far:



renewcommand{cite}[3]{
(vedi~ifthenelse{equal{#2}{#3}}
{parencite[pno~#2]{#1}}
{parencite[ppno~#2~hspace{-0.035cm}--hspace{-0.035cm}~#3]{#1}}hspace{0.035cm})\}


So if the input is



cite{book_1}{64}{64}


the output is



enter image description here



I'd like to modify is so that that output corresponds to the input



cite{book_1, 64}


if the initial and final cited pages are the same, and



cite{book_1, 64-65}


if they're different. Is there a way to do this?







biblatex bibliographies citing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 8 at 15:59









noibenoibe

32010




32010













  • Why do you want to do this, rather than just use the optional arguments to the cite command? e.g. cite[p.64]{book1}

    – Seamus
    Feb 8 at 16:34



















  • Why do you want to do this, rather than just use the optional arguments to the cite command? e.g. cite[p.64]{book1}

    – Seamus
    Feb 8 at 16:34

















Why do you want to do this, rather than just use the optional arguments to the cite command? e.g. cite[p.64]{book1}

– Seamus
Feb 8 at 16:34





Why do you want to do this, rather than just use the optional arguments to the cite command? e.g. cite[p.64]{book1}

– Seamus
Feb 8 at 16:34










1 Answer
1






active

oldest

votes


















2














Personally, I don't think the usual input




autocite[64]{sigfridsson}
autocite[64-65]{sigfridsson}



is too complicated or far inferior to cite{key}{64}{65}.



Here is a solution that only slightly modifies the macro mknormrange to drop the second page number if it is equal to the first. We then need to change around the order of commands in the postnote formats to give expected output with respect to "p."/"pp.". Then you can use the standard biblatex postnote syntax




autocite[<startpage>-<endpage>]{<key>}



documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{csquotes}

usepackage[style=authoryear, backend=biber]{biblatex}

addbibresource{biblatex-examples.bib}

DeclareFieldFormat{postnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
DeclareFieldFormat{volcitepages}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
DeclareFieldFormat{multipostnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}

makeatletter
defblx@normrange@process#1#2{%
ifstrequal{#1}{#2}
{blx@range@out@value{#1}}
{blx@range@out@value{#1bibrangedash#2}}}
makeatother

begin{document}
autocite[64-64]{sigfridsson}

autocite[64-65]{sigfridsson}

printbibliography
end{document}


(Sigfridsson and Ryde 1998, p. 64)//(Sigfridsson and Ryde 1998, pp. 64–65)






share|improve this answer

























    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%2f473949%2fcustom-cite-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









    2














    Personally, I don't think the usual input




    autocite[64]{sigfridsson}
    autocite[64-65]{sigfridsson}



    is too complicated or far inferior to cite{key}{64}{65}.



    Here is a solution that only slightly modifies the macro mknormrange to drop the second page number if it is equal to the first. We then need to change around the order of commands in the postnote formats to give expected output with respect to "p."/"pp.". Then you can use the standard biblatex postnote syntax




    autocite[<startpage>-<endpage>]{<key>}



    documentclass[british]{article}
    usepackage[T1]{fontenc}
    usepackage[utf8]{inputenc}
    usepackage{babel}
    usepackage{csquotes}

    usepackage[style=authoryear, backend=biber]{biblatex}

    addbibresource{biblatex-examples.bib}

    DeclareFieldFormat{postnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
    DeclareFieldFormat{volcitepages}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
    DeclareFieldFormat{multipostnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}

    makeatletter
    defblx@normrange@process#1#2{%
    ifstrequal{#1}{#2}
    {blx@range@out@value{#1}}
    {blx@range@out@value{#1bibrangedash#2}}}
    makeatother

    begin{document}
    autocite[64-64]{sigfridsson}

    autocite[64-65]{sigfridsson}

    printbibliography
    end{document}


    (Sigfridsson and Ryde 1998, p. 64)//(Sigfridsson and Ryde 1998, pp. 64–65)






    share|improve this answer






























      2














      Personally, I don't think the usual input




      autocite[64]{sigfridsson}
      autocite[64-65]{sigfridsson}



      is too complicated or far inferior to cite{key}{64}{65}.



      Here is a solution that only slightly modifies the macro mknormrange to drop the second page number if it is equal to the first. We then need to change around the order of commands in the postnote formats to give expected output with respect to "p."/"pp.". Then you can use the standard biblatex postnote syntax




      autocite[<startpage>-<endpage>]{<key>}



      documentclass[british]{article}
      usepackage[T1]{fontenc}
      usepackage[utf8]{inputenc}
      usepackage{babel}
      usepackage{csquotes}

      usepackage[style=authoryear, backend=biber]{biblatex}

      addbibresource{biblatex-examples.bib}

      DeclareFieldFormat{postnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
      DeclareFieldFormat{volcitepages}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
      DeclareFieldFormat{multipostnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}

      makeatletter
      defblx@normrange@process#1#2{%
      ifstrequal{#1}{#2}
      {blx@range@out@value{#1}}
      {blx@range@out@value{#1bibrangedash#2}}}
      makeatother

      begin{document}
      autocite[64-64]{sigfridsson}

      autocite[64-65]{sigfridsson}

      printbibliography
      end{document}


      (Sigfridsson and Ryde 1998, p. 64)//(Sigfridsson and Ryde 1998, pp. 64–65)






      share|improve this answer




























        2












        2








        2







        Personally, I don't think the usual input




        autocite[64]{sigfridsson}
        autocite[64-65]{sigfridsson}



        is too complicated or far inferior to cite{key}{64}{65}.



        Here is a solution that only slightly modifies the macro mknormrange to drop the second page number if it is equal to the first. We then need to change around the order of commands in the postnote formats to give expected output with respect to "p."/"pp.". Then you can use the standard biblatex postnote syntax




        autocite[<startpage>-<endpage>]{<key>}



        documentclass[british]{article}
        usepackage[T1]{fontenc}
        usepackage[utf8]{inputenc}
        usepackage{babel}
        usepackage{csquotes}

        usepackage[style=authoryear, backend=biber]{biblatex}

        addbibresource{biblatex-examples.bib}

        DeclareFieldFormat{postnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
        DeclareFieldFormat{volcitepages}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
        DeclareFieldFormat{multipostnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}

        makeatletter
        defblx@normrange@process#1#2{%
        ifstrequal{#1}{#2}
        {blx@range@out@value{#1}}
        {blx@range@out@value{#1bibrangedash#2}}}
        makeatother

        begin{document}
        autocite[64-64]{sigfridsson}

        autocite[64-65]{sigfridsson}

        printbibliography
        end{document}


        (Sigfridsson and Ryde 1998, p. 64)//(Sigfridsson and Ryde 1998, pp. 64–65)






        share|improve this answer















        Personally, I don't think the usual input




        autocite[64]{sigfridsson}
        autocite[64-65]{sigfridsson}



        is too complicated or far inferior to cite{key}{64}{65}.



        Here is a solution that only slightly modifies the macro mknormrange to drop the second page number if it is equal to the first. We then need to change around the order of commands in the postnote formats to give expected output with respect to "p."/"pp.". Then you can use the standard biblatex postnote syntax




        autocite[<startpage>-<endpage>]{<key>}



        documentclass[british]{article}
        usepackage[T1]{fontenc}
        usepackage[utf8]{inputenc}
        usepackage{babel}
        usepackage{csquotes}

        usepackage[style=authoryear, backend=biber]{biblatex}

        addbibresource{biblatex-examples.bib}

        DeclareFieldFormat{postnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
        DeclareFieldFormat{volcitepages}{mknormrange*[{mkpageprefix[pagination]}]{#1}}
        DeclareFieldFormat{multipostnote}{mknormrange*[{mkpageprefix[pagination]}]{#1}}

        makeatletter
        defblx@normrange@process#1#2{%
        ifstrequal{#1}{#2}
        {blx@range@out@value{#1}}
        {blx@range@out@value{#1bibrangedash#2}}}
        makeatother

        begin{document}
        autocite[64-64]{sigfridsson}

        autocite[64-65]{sigfridsson}

        printbibliography
        end{document}


        (Sigfridsson and Ryde 1998, p. 64)//(Sigfridsson and Ryde 1998, pp. 64–65)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 8 at 16:56

























        answered Feb 8 at 16:35









        moewemoewe

        91.2k10114343




        91.2k10114343






























            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%2f473949%2fcustom-cite-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

            How to change which sound is reproduced for terminal bell?

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

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents