Multiple listing styles with caption packageMultiple listings styles“Listing #” below listings without a...

What does "enim et" mean?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Where else does the Shulchan Aruch quote an authority by name?

Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?

Where to refill my bottle in India?

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

Is a vector space a subspace of itself?

What is it called when one voice type sings a 'solo'?

How to manage monthly salary

What causes the sudden spool-up sound from an F-16 when enabling afterburner?

Typesetting a double Over Dot on top of a symbol

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

What is the meaning of "of trouble" in the following sentence?

Are white and non-white police officers equally likely to kill black suspects?

Does it makes sense to buy a new cycle to learn riding?

What does 'script /dev/null' do?

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

Denied boarding due to overcrowding, Sparpreis ticket. What are my rights?

Landing in very high winds

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?

What do the Banks children have against barley water?

COUNT(*) or MAX(id) - which is faster?

Is there any use for defining additional entity types in a SOQL FROM clause?



Multiple listing styles with caption package


Multiple listings styles“Listing #” below listings without a captionCaption for a listingCenter caption in listingMultiple listings stylesCode caption with listing without title, only numberslist of figures and tables when there are no figures or tables?change caption of multiple listing styleslisting caption with a break lineHow to correctly align caption with code listingSpace between caption and listing













1















This question is mainly related to Multiple listings styles. If I have usepackage{caption} definition in the head of file, list of custom listings disappear. How to make it work?



documentclass{article}
usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
usepackage{listings}% http://ctan.org/pkg/listings
usepackage{caption}
makeatletter
% --------------------------------------- C++
newcommand{lstlistcplusplusname}{List of C++}
lst@UserCommandlstlistofcplusplus{bgroup
letcontentsnamelstlistcplusplusname
letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
tableofcontents egroup}
lstnewenvironment{cplusplus}[1][]{%
renewcommand{lstlistingname}{C++ Code}%
xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
lstset{language=C++,#1}}
{}
% --------------------------------------- R
newcommand{lstlistrcodename}{List of R}
lst@UserCommandlstlistofrcode{bgroup
letcontentsnamelstlistrcodename
letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
tableofcontents egroup}
lstnewenvironment{rcode}[1][]{%
renewcommand{lstlistingname}{R Code}%
xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
lstset{language=R,#1}}
{}
% --------------------------------------- Pseudocode
newcommand{lstlistpseudocodename}{List of Pseudocode}
lst@UserCommandlstlistofpseudocode{bgroup
letcontentsnamelstlistpseudocodename
letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
tableofcontents egroup}
lstnewenvironment{pseudocode}[1][]{%
renewcommand{lstlistingname}{Pseudocode}%
xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
lstset{basicstyle=ttfamily,#1}}
{}
makeatother
begin{document}

lstlistofcplusplus
lstlistofrcode
lstlistofpseudocode

begin{cplusplus}[caption={Hello world}]
// 'Hello World!' program

#include <iostream>

int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
end{cplusplus}

begin{rcode}[caption={Hello world}]
cat('Hello, world!n')
end{rcode}

begin{pseudocode}[caption={Hello world}]
print "Hello world"
end{pseudocode}

end{document}









share|improve this question







New contributor




Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    This question is mainly related to Multiple listings styles. If I have usepackage{caption} definition in the head of file, list of custom listings disappear. How to make it work?



    documentclass{article}
    usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
    usepackage{listings}% http://ctan.org/pkg/listings
    usepackage{caption}
    makeatletter
    % --------------------------------------- C++
    newcommand{lstlistcplusplusname}{List of C++}
    lst@UserCommandlstlistofcplusplus{bgroup
    letcontentsnamelstlistcplusplusname
    letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
    tableofcontents egroup}
    lstnewenvironment{cplusplus}[1][]{%
    renewcommand{lstlistingname}{C++ Code}%
    xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
    lstset{language=C++,#1}}
    {}
    % --------------------------------------- R
    newcommand{lstlistrcodename}{List of R}
    lst@UserCommandlstlistofrcode{bgroup
    letcontentsnamelstlistrcodename
    letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
    tableofcontents egroup}
    lstnewenvironment{rcode}[1][]{%
    renewcommand{lstlistingname}{R Code}%
    xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
    lstset{language=R,#1}}
    {}
    % --------------------------------------- Pseudocode
    newcommand{lstlistpseudocodename}{List of Pseudocode}
    lst@UserCommandlstlistofpseudocode{bgroup
    letcontentsnamelstlistpseudocodename
    letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
    tableofcontents egroup}
    lstnewenvironment{pseudocode}[1][]{%
    renewcommand{lstlistingname}{Pseudocode}%
    xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
    lstset{basicstyle=ttfamily,#1}}
    {}
    makeatother
    begin{document}

    lstlistofcplusplus
    lstlistofrcode
    lstlistofpseudocode

    begin{cplusplus}[caption={Hello world}]
    // 'Hello World!' program

    #include <iostream>

    int main()
    {
    std::cout << "Hello World!" << std::endl;
    return 0;
    }
    end{cplusplus}

    begin{rcode}[caption={Hello world}]
    cat('Hello, world!n')
    end{rcode}

    begin{pseudocode}[caption={Hello world}]
    print "Hello world"
    end{pseudocode}

    end{document}









    share|improve this question







    New contributor




    Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      This question is mainly related to Multiple listings styles. If I have usepackage{caption} definition in the head of file, list of custom listings disappear. How to make it work?



      documentclass{article}
      usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
      usepackage{listings}% http://ctan.org/pkg/listings
      usepackage{caption}
      makeatletter
      % --------------------------------------- C++
      newcommand{lstlistcplusplusname}{List of C++}
      lst@UserCommandlstlistofcplusplus{bgroup
      letcontentsnamelstlistcplusplusname
      letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
      tableofcontents egroup}
      lstnewenvironment{cplusplus}[1][]{%
      renewcommand{lstlistingname}{C++ Code}%
      xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
      lstset{language=C++,#1}}
      {}
      % --------------------------------------- R
      newcommand{lstlistrcodename}{List of R}
      lst@UserCommandlstlistofrcode{bgroup
      letcontentsnamelstlistrcodename
      letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
      tableofcontents egroup}
      lstnewenvironment{rcode}[1][]{%
      renewcommand{lstlistingname}{R Code}%
      xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
      lstset{language=R,#1}}
      {}
      % --------------------------------------- Pseudocode
      newcommand{lstlistpseudocodename}{List of Pseudocode}
      lst@UserCommandlstlistofpseudocode{bgroup
      letcontentsnamelstlistpseudocodename
      letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
      tableofcontents egroup}
      lstnewenvironment{pseudocode}[1][]{%
      renewcommand{lstlistingname}{Pseudocode}%
      xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
      lstset{basicstyle=ttfamily,#1}}
      {}
      makeatother
      begin{document}

      lstlistofcplusplus
      lstlistofrcode
      lstlistofpseudocode

      begin{cplusplus}[caption={Hello world}]
      // 'Hello World!' program

      #include <iostream>

      int main()
      {
      std::cout << "Hello World!" << std::endl;
      return 0;
      }
      end{cplusplus}

      begin{rcode}[caption={Hello world}]
      cat('Hello, world!n')
      end{rcode}

      begin{pseudocode}[caption={Hello world}]
      print "Hello world"
      end{pseudocode}

      end{document}









      share|improve this question







      New contributor




      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      This question is mainly related to Multiple listings styles. If I have usepackage{caption} definition in the head of file, list of custom listings disappear. How to make it work?



      documentclass{article}
      usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
      usepackage{listings}% http://ctan.org/pkg/listings
      usepackage{caption}
      makeatletter
      % --------------------------------------- C++
      newcommand{lstlistcplusplusname}{List of C++}
      lst@UserCommandlstlistofcplusplus{bgroup
      letcontentsnamelstlistcplusplusname
      letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
      tableofcontents egroup}
      lstnewenvironment{cplusplus}[1][]{%
      renewcommand{lstlistingname}{C++ Code}%
      xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
      lstset{language=C++,#1}}
      {}
      % --------------------------------------- R
      newcommand{lstlistrcodename}{List of R}
      lst@UserCommandlstlistofrcode{bgroup
      letcontentsnamelstlistrcodename
      letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
      tableofcontents egroup}
      lstnewenvironment{rcode}[1][]{%
      renewcommand{lstlistingname}{R Code}%
      xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
      lstset{language=R,#1}}
      {}
      % --------------------------------------- Pseudocode
      newcommand{lstlistpseudocodename}{List of Pseudocode}
      lst@UserCommandlstlistofpseudocode{bgroup
      letcontentsnamelstlistpseudocodename
      letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
      tableofcontents egroup}
      lstnewenvironment{pseudocode}[1][]{%
      renewcommand{lstlistingname}{Pseudocode}%
      xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
      lstset{basicstyle=ttfamily,#1}}
      {}
      makeatother
      begin{document}

      lstlistofcplusplus
      lstlistofrcode
      lstlistofpseudocode

      begin{cplusplus}[caption={Hello world}]
      // 'Hello World!' program

      #include <iostream>

      int main()
      {
      std::cout << "Hello World!" << std::endl;
      return 0;
      }
      end{cplusplus}

      begin{rcode}[caption={Hello world}]
      cat('Hello, world!n')
      end{rcode}

      begin{pseudocode}[caption={Hello world}]
      print "Hello world"
      end{pseudocode}

      end{document}






      table-of-contents captions listings naming






      share|improve this question







      New contributor




      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 17 hours ago









      SezenSezen

      133




      133




      New contributor




      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Sezen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          0














          I don't know for sure, but I think ,there's a clash between the regexpatch package and the caption package. As an alternative to the caption package, I found the capt-of package in CTAN. When I used this package everything worked smoothly.



          documentclass{article}
          usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
          usepackage{listings}% http://ctan.org/pkg/listings
          usepackage{capt-of}
          usepackage{graphicx}
          makeatletter
          % --------------------------------------- C++
          newcommand{lstlistcplusplusname}{List of C++}
          lst@UserCommandlstlistofcplusplus{bgroup
          letcontentsnamelstlistcplusplusname
          letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
          tableofcontents egroup}
          lstnewenvironment{cplusplus}[1][]{%
          renewcommand{lstlistingname}{C++ Code}%
          xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
          lstset{language=C++,#1}}
          {}
          % --------------------------------------- R
          newcommand{lstlistrcodename}{List of R}
          lst@UserCommandlstlistofrcode{bgroup
          letcontentsnamelstlistrcodename
          letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
          tableofcontents egroup}
          lstnewenvironment{rcode}[1][]{%
          renewcommand{lstlistingname}{R Code}%
          xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
          lstset{language=R,#1}}
          {}
          % --------------------------------------- Pseudocode
          newcommand{lstlistpseudocodename}{List of Pseudocode}
          lst@UserCommandlstlistofpseudocode{bgroup
          letcontentsnamelstlistpseudocodename
          letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
          tableofcontents egroup}
          lstnewenvironment{pseudocode}[1][]{%
          renewcommand{lstlistingname}{Pseudocode}%
          xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
          lstset{basicstyle=ttfamily,#1}}
          {}
          makeatother
          begin{document}

          lstlistofcplusplus
          lstlistofrcode
          lstlistofpseudocode

          begin{cplusplus}[caption={Hello world}]
          // 'Hello World!' program

          #include <iostream>

          int main()
          {
          std::cout << "Hello World!" << std::endl;
          return 0;
          }
          end{cplusplus}

          begin{rcode}[caption={Hello world}]
          cat('Hello, world!n')
          end{rcode}

          begin{pseudocode}[caption={Hello world}]
          print "Hello world"
          end{pseudocode}

          begin{figure}[h]
          centering
          includegraphics[scale=0.5]{example-image-a}
          captionof{figure}{Example image a.}
          end{figure}

          end{document}


          enter image description here






          share|improve this answer


























          • Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

            – Sezen
            14 hours ago











          • It's not clear to me why do you think this is a clash between regexpatch and caption.

            – Axel Sommerfeldt
            9 hours ago











          • As I said, it was just the assumption.

            – ferahfeza
            9 hours ago



















          0














          The caption package needs to patch lst@MakeCaption to adapt the listings package to the features of the caption package. It stores (and uses) the original definition of lst@MakeCaption into a macro called caption@ORI@lst@MakeCaption, so to make your solution work, this macro needs to be patched:

          documentclass{article}
          usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
          usepackage{listings}% http://ctan.org/pkg/listings
          usepackage{caption}
          makeatletter
          % --------------------------------------- C++
          newcommand{lstlistcplusplusname}{List of C++}
          lst@UserCommandlstlistofcplusplus{bgroup
          letcontentsnamelstlistcplusplusname
          letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
          tableofcontents egroup}
          lstnewenvironment{cplusplus}[1][]{%
          renewcommand{lstlistingname}{C++ Code}%
          xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
          xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{loc}{}{}%
          lstset{language=C++,#1}}
          {}
          % --------------------------------------- R
          newcommand{lstlistrcodename}{List of R}
          lst@UserCommandlstlistofrcode{bgroup
          letcontentsnamelstlistrcodename
          letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
          tableofcontents egroup}
          lstnewenvironment{rcode}[1][]{%
          renewcommand{lstlistingname}{R Code}%
          xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
          xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lor}{}{}%
          lstset{language=R,#1}}
          {}
          % --------------------------------------- Pseudocode
          newcommand{lstlistpseudocodename}{List of Pseudocode}
          lst@UserCommandlstlistofpseudocode{bgroup
          letcontentsnamelstlistpseudocodename
          letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
          tableofcontents egroup}
          lstnewenvironment{pseudocode}[1][]{%
          renewcommand{lstlistingname}{Pseudocode}%
          xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
          xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lop}{}{}%
          lstset{basicstyle=ttfamily,#1}}
          {}
          makeatother
          begin{document}



          lstlistofcplusplus
          lstlistofrcode
          lstlistofpseudocode



          begin{cplusplus}[caption={Hello world}]
          // 'Hello World!' program



          include



          int main()
          {
          std::cout << "Hello World!" << std::endl;
          return 0;
          }
          end{cplusplus}



          begin{rcode}[caption={Hello world}]
          cat('Hello, world!n')
          end{rcode}



          begin{pseudocode}[caption={Hello world}]
          print "Hello world"
          end{pseudocode}



          end{document}



          It's a pity that the listings feature does not define and use defext@lstlisting{lol}, like all other environments which do offer a "List of" feature. In this case redefining ext@lstlisting would be sufficient, with and without caption package (or any other package patching lst@MakeCaption).






          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
            });


            }
            });






            Sezen is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f483775%2fmultiple-listing-styles-with-caption-package%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I don't know for sure, but I think ,there's a clash between the regexpatch package and the caption package. As an alternative to the caption package, I found the capt-of package in CTAN. When I used this package everything worked smoothly.



            documentclass{article}
            usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
            usepackage{listings}% http://ctan.org/pkg/listings
            usepackage{capt-of}
            usepackage{graphicx}
            makeatletter
            % --------------------------------------- C++
            newcommand{lstlistcplusplusname}{List of C++}
            lst@UserCommandlstlistofcplusplus{bgroup
            letcontentsnamelstlistcplusplusname
            letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
            tableofcontents egroup}
            lstnewenvironment{cplusplus}[1][]{%
            renewcommand{lstlistingname}{C++ Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
            lstset{language=C++,#1}}
            {}
            % --------------------------------------- R
            newcommand{lstlistrcodename}{List of R}
            lst@UserCommandlstlistofrcode{bgroup
            letcontentsnamelstlistrcodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
            tableofcontents egroup}
            lstnewenvironment{rcode}[1][]{%
            renewcommand{lstlistingname}{R Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
            lstset{language=R,#1}}
            {}
            % --------------------------------------- Pseudocode
            newcommand{lstlistpseudocodename}{List of Pseudocode}
            lst@UserCommandlstlistofpseudocode{bgroup
            letcontentsnamelstlistpseudocodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
            tableofcontents egroup}
            lstnewenvironment{pseudocode}[1][]{%
            renewcommand{lstlistingname}{Pseudocode}%
            xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
            lstset{basicstyle=ttfamily,#1}}
            {}
            makeatother
            begin{document}

            lstlistofcplusplus
            lstlistofrcode
            lstlistofpseudocode

            begin{cplusplus}[caption={Hello world}]
            // 'Hello World!' program

            #include <iostream>

            int main()
            {
            std::cout << "Hello World!" << std::endl;
            return 0;
            }
            end{cplusplus}

            begin{rcode}[caption={Hello world}]
            cat('Hello, world!n')
            end{rcode}

            begin{pseudocode}[caption={Hello world}]
            print "Hello world"
            end{pseudocode}

            begin{figure}[h]
            centering
            includegraphics[scale=0.5]{example-image-a}
            captionof{figure}{Example image a.}
            end{figure}

            end{document}


            enter image description here






            share|improve this answer


























            • Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

              – Sezen
              14 hours ago











            • It's not clear to me why do you think this is a clash between regexpatch and caption.

              – Axel Sommerfeldt
              9 hours ago











            • As I said, it was just the assumption.

              – ferahfeza
              9 hours ago
















            0














            I don't know for sure, but I think ,there's a clash between the regexpatch package and the caption package. As an alternative to the caption package, I found the capt-of package in CTAN. When I used this package everything worked smoothly.



            documentclass{article}
            usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
            usepackage{listings}% http://ctan.org/pkg/listings
            usepackage{capt-of}
            usepackage{graphicx}
            makeatletter
            % --------------------------------------- C++
            newcommand{lstlistcplusplusname}{List of C++}
            lst@UserCommandlstlistofcplusplus{bgroup
            letcontentsnamelstlistcplusplusname
            letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
            tableofcontents egroup}
            lstnewenvironment{cplusplus}[1][]{%
            renewcommand{lstlistingname}{C++ Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
            lstset{language=C++,#1}}
            {}
            % --------------------------------------- R
            newcommand{lstlistrcodename}{List of R}
            lst@UserCommandlstlistofrcode{bgroup
            letcontentsnamelstlistrcodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
            tableofcontents egroup}
            lstnewenvironment{rcode}[1][]{%
            renewcommand{lstlistingname}{R Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
            lstset{language=R,#1}}
            {}
            % --------------------------------------- Pseudocode
            newcommand{lstlistpseudocodename}{List of Pseudocode}
            lst@UserCommandlstlistofpseudocode{bgroup
            letcontentsnamelstlistpseudocodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
            tableofcontents egroup}
            lstnewenvironment{pseudocode}[1][]{%
            renewcommand{lstlistingname}{Pseudocode}%
            xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
            lstset{basicstyle=ttfamily,#1}}
            {}
            makeatother
            begin{document}

            lstlistofcplusplus
            lstlistofrcode
            lstlistofpseudocode

            begin{cplusplus}[caption={Hello world}]
            // 'Hello World!' program

            #include <iostream>

            int main()
            {
            std::cout << "Hello World!" << std::endl;
            return 0;
            }
            end{cplusplus}

            begin{rcode}[caption={Hello world}]
            cat('Hello, world!n')
            end{rcode}

            begin{pseudocode}[caption={Hello world}]
            print "Hello world"
            end{pseudocode}

            begin{figure}[h]
            centering
            includegraphics[scale=0.5]{example-image-a}
            captionof{figure}{Example image a.}
            end{figure}

            end{document}


            enter image description here






            share|improve this answer


























            • Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

              – Sezen
              14 hours ago











            • It's not clear to me why do you think this is a clash between regexpatch and caption.

              – Axel Sommerfeldt
              9 hours ago











            • As I said, it was just the assumption.

              – ferahfeza
              9 hours ago














            0












            0








            0







            I don't know for sure, but I think ,there's a clash between the regexpatch package and the caption package. As an alternative to the caption package, I found the capt-of package in CTAN. When I used this package everything worked smoothly.



            documentclass{article}
            usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
            usepackage{listings}% http://ctan.org/pkg/listings
            usepackage{capt-of}
            usepackage{graphicx}
            makeatletter
            % --------------------------------------- C++
            newcommand{lstlistcplusplusname}{List of C++}
            lst@UserCommandlstlistofcplusplus{bgroup
            letcontentsnamelstlistcplusplusname
            letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
            tableofcontents egroup}
            lstnewenvironment{cplusplus}[1][]{%
            renewcommand{lstlistingname}{C++ Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
            lstset{language=C++,#1}}
            {}
            % --------------------------------------- R
            newcommand{lstlistrcodename}{List of R}
            lst@UserCommandlstlistofrcode{bgroup
            letcontentsnamelstlistrcodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
            tableofcontents egroup}
            lstnewenvironment{rcode}[1][]{%
            renewcommand{lstlistingname}{R Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
            lstset{language=R,#1}}
            {}
            % --------------------------------------- Pseudocode
            newcommand{lstlistpseudocodename}{List of Pseudocode}
            lst@UserCommandlstlistofpseudocode{bgroup
            letcontentsnamelstlistpseudocodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
            tableofcontents egroup}
            lstnewenvironment{pseudocode}[1][]{%
            renewcommand{lstlistingname}{Pseudocode}%
            xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
            lstset{basicstyle=ttfamily,#1}}
            {}
            makeatother
            begin{document}

            lstlistofcplusplus
            lstlistofrcode
            lstlistofpseudocode

            begin{cplusplus}[caption={Hello world}]
            // 'Hello World!' program

            #include <iostream>

            int main()
            {
            std::cout << "Hello World!" << std::endl;
            return 0;
            }
            end{cplusplus}

            begin{rcode}[caption={Hello world}]
            cat('Hello, world!n')
            end{rcode}

            begin{pseudocode}[caption={Hello world}]
            print "Hello world"
            end{pseudocode}

            begin{figure}[h]
            centering
            includegraphics[scale=0.5]{example-image-a}
            captionof{figure}{Example image a.}
            end{figure}

            end{document}


            enter image description here






            share|improve this answer















            I don't know for sure, but I think ,there's a clash between the regexpatch package and the caption package. As an alternative to the caption package, I found the capt-of package in CTAN. When I used this package everything worked smoothly.



            documentclass{article}
            usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
            usepackage{listings}% http://ctan.org/pkg/listings
            usepackage{capt-of}
            usepackage{graphicx}
            makeatletter
            % --------------------------------------- C++
            newcommand{lstlistcplusplusname}{List of C++}
            lst@UserCommandlstlistofcplusplus{bgroup
            letcontentsnamelstlistcplusplusname
            letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
            tableofcontents egroup}
            lstnewenvironment{cplusplus}[1][]{%
            renewcommand{lstlistingname}{C++ Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
            lstset{language=C++,#1}}
            {}
            % --------------------------------------- R
            newcommand{lstlistrcodename}{List of R}
            lst@UserCommandlstlistofrcode{bgroup
            letcontentsnamelstlistrcodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
            tableofcontents egroup}
            lstnewenvironment{rcode}[1][]{%
            renewcommand{lstlistingname}{R Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
            lstset{language=R,#1}}
            {}
            % --------------------------------------- Pseudocode
            newcommand{lstlistpseudocodename}{List of Pseudocode}
            lst@UserCommandlstlistofpseudocode{bgroup
            letcontentsnamelstlistpseudocodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
            tableofcontents egroup}
            lstnewenvironment{pseudocode}[1][]{%
            renewcommand{lstlistingname}{Pseudocode}%
            xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
            lstset{basicstyle=ttfamily,#1}}
            {}
            makeatother
            begin{document}

            lstlistofcplusplus
            lstlistofrcode
            lstlistofpseudocode

            begin{cplusplus}[caption={Hello world}]
            // 'Hello World!' program

            #include <iostream>

            int main()
            {
            std::cout << "Hello World!" << std::endl;
            return 0;
            }
            end{cplusplus}

            begin{rcode}[caption={Hello world}]
            cat('Hello, world!n')
            end{rcode}

            begin{pseudocode}[caption={Hello world}]
            print "Hello world"
            end{pseudocode}

            begin{figure}[h]
            centering
            includegraphics[scale=0.5]{example-image-a}
            captionof{figure}{Example image a.}
            end{figure}

            end{document}


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 14 hours ago

























            answered 14 hours ago









            ferahfezaferahfeza

            7,41411933




            7,41411933













            • Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

              – Sezen
              14 hours ago











            • It's not clear to me why do you think this is a clash between regexpatch and caption.

              – Axel Sommerfeldt
              9 hours ago











            • As I said, it was just the assumption.

              – ferahfeza
              9 hours ago



















            • Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

              – Sezen
              14 hours ago











            • It's not clear to me why do you think this is a clash between regexpatch and caption.

              – Axel Sommerfeldt
              9 hours ago











            • As I said, it was just the assumption.

              – ferahfeza
              9 hours ago

















            Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

            – Sezen
            14 hours ago





            Thanks for the answer but caption is widely used package and has a lot of methods like captionsetup to change captions. I really would like to have a solution with caption package.

            – Sezen
            14 hours ago













            It's not clear to me why do you think this is a clash between regexpatch and caption.

            – Axel Sommerfeldt
            9 hours ago





            It's not clear to me why do you think this is a clash between regexpatch and caption.

            – Axel Sommerfeldt
            9 hours ago













            As I said, it was just the assumption.

            – ferahfeza
            9 hours ago





            As I said, it was just the assumption.

            – ferahfeza
            9 hours ago











            0














            The caption package needs to patch lst@MakeCaption to adapt the listings package to the features of the caption package. It stores (and uses) the original definition of lst@MakeCaption into a macro called caption@ORI@lst@MakeCaption, so to make your solution work, this macro needs to be patched:

            documentclass{article}
            usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
            usepackage{listings}% http://ctan.org/pkg/listings
            usepackage{caption}
            makeatletter
            % --------------------------------------- C++
            newcommand{lstlistcplusplusname}{List of C++}
            lst@UserCommandlstlistofcplusplus{bgroup
            letcontentsnamelstlistcplusplusname
            letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
            tableofcontents egroup}
            lstnewenvironment{cplusplus}[1][]{%
            renewcommand{lstlistingname}{C++ Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
            xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{loc}{}{}%
            lstset{language=C++,#1}}
            {}
            % --------------------------------------- R
            newcommand{lstlistrcodename}{List of R}
            lst@UserCommandlstlistofrcode{bgroup
            letcontentsnamelstlistrcodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
            tableofcontents egroup}
            lstnewenvironment{rcode}[1][]{%
            renewcommand{lstlistingname}{R Code}%
            xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
            xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lor}{}{}%
            lstset{language=R,#1}}
            {}
            % --------------------------------------- Pseudocode
            newcommand{lstlistpseudocodename}{List of Pseudocode}
            lst@UserCommandlstlistofpseudocode{bgroup
            letcontentsnamelstlistpseudocodename
            letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
            tableofcontents egroup}
            lstnewenvironment{pseudocode}[1][]{%
            renewcommand{lstlistingname}{Pseudocode}%
            xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
            xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lop}{}{}%
            lstset{basicstyle=ttfamily,#1}}
            {}
            makeatother
            begin{document}



            lstlistofcplusplus
            lstlistofrcode
            lstlistofpseudocode



            begin{cplusplus}[caption={Hello world}]
            // 'Hello World!' program



            include



            int main()
            {
            std::cout << "Hello World!" << std::endl;
            return 0;
            }
            end{cplusplus}



            begin{rcode}[caption={Hello world}]
            cat('Hello, world!n')
            end{rcode}



            begin{pseudocode}[caption={Hello world}]
            print "Hello world"
            end{pseudocode}



            end{document}



            It's a pity that the listings feature does not define and use defext@lstlisting{lol}, like all other environments which do offer a "List of" feature. In this case redefining ext@lstlisting would be sufficient, with and without caption package (or any other package patching lst@MakeCaption).






            share|improve this answer




























              0














              The caption package needs to patch lst@MakeCaption to adapt the listings package to the features of the caption package. It stores (and uses) the original definition of lst@MakeCaption into a macro called caption@ORI@lst@MakeCaption, so to make your solution work, this macro needs to be patched:

              documentclass{article}
              usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
              usepackage{listings}% http://ctan.org/pkg/listings
              usepackage{caption}
              makeatletter
              % --------------------------------------- C++
              newcommand{lstlistcplusplusname}{List of C++}
              lst@UserCommandlstlistofcplusplus{bgroup
              letcontentsnamelstlistcplusplusname
              letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
              tableofcontents egroup}
              lstnewenvironment{cplusplus}[1][]{%
              renewcommand{lstlistingname}{C++ Code}%
              xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
              xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{loc}{}{}%
              lstset{language=C++,#1}}
              {}
              % --------------------------------------- R
              newcommand{lstlistrcodename}{List of R}
              lst@UserCommandlstlistofrcode{bgroup
              letcontentsnamelstlistrcodename
              letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
              tableofcontents egroup}
              lstnewenvironment{rcode}[1][]{%
              renewcommand{lstlistingname}{R Code}%
              xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
              xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lor}{}{}%
              lstset{language=R,#1}}
              {}
              % --------------------------------------- Pseudocode
              newcommand{lstlistpseudocodename}{List of Pseudocode}
              lst@UserCommandlstlistofpseudocode{bgroup
              letcontentsnamelstlistpseudocodename
              letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
              tableofcontents egroup}
              lstnewenvironment{pseudocode}[1][]{%
              renewcommand{lstlistingname}{Pseudocode}%
              xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
              xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lop}{}{}%
              lstset{basicstyle=ttfamily,#1}}
              {}
              makeatother
              begin{document}



              lstlistofcplusplus
              lstlistofrcode
              lstlistofpseudocode



              begin{cplusplus}[caption={Hello world}]
              // 'Hello World!' program



              include



              int main()
              {
              std::cout << "Hello World!" << std::endl;
              return 0;
              }
              end{cplusplus}



              begin{rcode}[caption={Hello world}]
              cat('Hello, world!n')
              end{rcode}



              begin{pseudocode}[caption={Hello world}]
              print "Hello world"
              end{pseudocode}



              end{document}



              It's a pity that the listings feature does not define and use defext@lstlisting{lol}, like all other environments which do offer a "List of" feature. In this case redefining ext@lstlisting would be sufficient, with and without caption package (or any other package patching lst@MakeCaption).






              share|improve this answer


























                0












                0








                0







                The caption package needs to patch lst@MakeCaption to adapt the listings package to the features of the caption package. It stores (and uses) the original definition of lst@MakeCaption into a macro called caption@ORI@lst@MakeCaption, so to make your solution work, this macro needs to be patched:

                documentclass{article}
                usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
                usepackage{listings}% http://ctan.org/pkg/listings
                usepackage{caption}
                makeatletter
                % --------------------------------------- C++
                newcommand{lstlistcplusplusname}{List of C++}
                lst@UserCommandlstlistofcplusplus{bgroup
                letcontentsnamelstlistcplusplusname
                letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
                tableofcontents egroup}
                lstnewenvironment{cplusplus}[1][]{%
                renewcommand{lstlistingname}{C++ Code}%
                xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
                xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{loc}{}{}%
                lstset{language=C++,#1}}
                {}
                % --------------------------------------- R
                newcommand{lstlistrcodename}{List of R}
                lst@UserCommandlstlistofrcode{bgroup
                letcontentsnamelstlistrcodename
                letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
                tableofcontents egroup}
                lstnewenvironment{rcode}[1][]{%
                renewcommand{lstlistingname}{R Code}%
                xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
                xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lor}{}{}%
                lstset{language=R,#1}}
                {}
                % --------------------------------------- Pseudocode
                newcommand{lstlistpseudocodename}{List of Pseudocode}
                lst@UserCommandlstlistofpseudocode{bgroup
                letcontentsnamelstlistpseudocodename
                letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
                tableofcontents egroup}
                lstnewenvironment{pseudocode}[1][]{%
                renewcommand{lstlistingname}{Pseudocode}%
                xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
                xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lop}{}{}%
                lstset{basicstyle=ttfamily,#1}}
                {}
                makeatother
                begin{document}



                lstlistofcplusplus
                lstlistofrcode
                lstlistofpseudocode



                begin{cplusplus}[caption={Hello world}]
                // 'Hello World!' program



                include



                int main()
                {
                std::cout << "Hello World!" << std::endl;
                return 0;
                }
                end{cplusplus}



                begin{rcode}[caption={Hello world}]
                cat('Hello, world!n')
                end{rcode}



                begin{pseudocode}[caption={Hello world}]
                print "Hello world"
                end{pseudocode}



                end{document}



                It's a pity that the listings feature does not define and use defext@lstlisting{lol}, like all other environments which do offer a "List of" feature. In this case redefining ext@lstlisting would be sufficient, with and without caption package (or any other package patching lst@MakeCaption).






                share|improve this answer













                The caption package needs to patch lst@MakeCaption to adapt the listings package to the features of the caption package. It stores (and uses) the original definition of lst@MakeCaption into a macro called caption@ORI@lst@MakeCaption, so to make your solution work, this macro needs to be patched:

                documentclass{article}
                usepackage{regexpatch}% http://ctan.org/pkg/regexpatch
                usepackage{listings}% http://ctan.org/pkg/listings
                usepackage{caption}
                makeatletter
                % --------------------------------------- C++
                newcommand{lstlistcplusplusname}{List of C++}
                lst@UserCommandlstlistofcplusplus{bgroup
                letcontentsnamelstlistcplusplusname
                letlst@temp@starttoc def@starttoc##1{lst@temp{loc}}%
                tableofcontents egroup}
                lstnewenvironment{cplusplus}[1][]{%
                renewcommand{lstlistingname}{C++ Code}%
                xpatchcmd*{lst@MakeCaption}{lol}{loc}{}{}%
                xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{loc}{}{}%
                lstset{language=C++,#1}}
                {}
                % --------------------------------------- R
                newcommand{lstlistrcodename}{List of R}
                lst@UserCommandlstlistofrcode{bgroup
                letcontentsnamelstlistrcodename
                letlst@temp@starttoc def@starttoc##1{lst@temp{lor}}%
                tableofcontents egroup}
                lstnewenvironment{rcode}[1][]{%
                renewcommand{lstlistingname}{R Code}%
                xpatchcmd*{lst@MakeCaption}{lol}{lor}{}{}%
                xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lor}{}{}%
                lstset{language=R,#1}}
                {}
                % --------------------------------------- Pseudocode
                newcommand{lstlistpseudocodename}{List of Pseudocode}
                lst@UserCommandlstlistofpseudocode{bgroup
                letcontentsnamelstlistpseudocodename
                letlst@temp@starttoc def@starttoc##1{lst@temp{lop}}%
                tableofcontents egroup}
                lstnewenvironment{pseudocode}[1][]{%
                renewcommand{lstlistingname}{Pseudocode}%
                xpatchcmd*{lst@MakeCaption}{lol}{lop}{}{}%
                xpatchcmd*{caption@ORI@lst@MakeCaption}{lol}{lop}{}{}%
                lstset{basicstyle=ttfamily,#1}}
                {}
                makeatother
                begin{document}



                lstlistofcplusplus
                lstlistofrcode
                lstlistofpseudocode



                begin{cplusplus}[caption={Hello world}]
                // 'Hello World!' program



                include



                int main()
                {
                std::cout << "Hello World!" << std::endl;
                return 0;
                }
                end{cplusplus}



                begin{rcode}[caption={Hello world}]
                cat('Hello, world!n')
                end{rcode}



                begin{pseudocode}[caption={Hello world}]
                print "Hello world"
                end{pseudocode}



                end{document}



                It's a pity that the listings feature does not define and use defext@lstlisting{lol}, like all other environments which do offer a "List of" feature. In this case redefining ext@lstlisting would be sufficient, with and without caption package (or any other package patching lst@MakeCaption).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 9 hours ago









                Axel SommerfeldtAxel Sommerfeldt

                12.2k22855




                12.2k22855






















                    Sezen is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Sezen is a new contributor. Be nice, and check out our Code of Conduct.













                    Sezen is a new contributor. Be nice, and check out our Code of Conduct.












                    Sezen is a new contributor. Be nice, and check out our Code of Conduct.
















                    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%2f483775%2fmultiple-listing-styles-with-caption-package%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

                    El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

                    Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...

                    Castillo d'Acher Características Menú de navegación