Problem with vertical alignment of a multicolumn listing in a tcolorbox Unicorn Meta Zoo #1:...

Additive group of local rings

How to count in linear time worst-case?

How would I use different systems of magic when they are capable of the same effects?

Israeli soda type drink

How to translate "red flag" into Spanish?

std::is_constructible on incomplete types

Error: Syntax error. Missing ')' for CASE Statement

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?

Need of separate security plugins for both root and subfolder sites Wordpress?

Split coins into combinations of different denominations

How to keep bees out of canned beverages?

Mistake in years of experience in resume?

Implementing 3DES algorithm in Java: is my code secure?

Suing a Police Officer Instead of the Police Department

Is Bran literally the world's memory?

Would reducing the reference voltage of an ADC have any effect on accuracy?

Is it acceptable to use working hours to read general interest books?

With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space

What is the term for a person whose job is to place products on shelves in stores?

c++ diamond problem - How to call base method only once

How to get even lighting when using flash for group photos near wall?

Co-worker works way more than he should

I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?



Problem with vertical alignment of a multicolumn listing in a tcolorbox



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraProblem with Table Vertical AlignmentProblem with alignment in listingstcolorbox - list of listings?Vertical alignment of “nobeforeafter” tcolorboxVertical spacing vfill inside tcolorboxVertical alignment problemEquations in tcolorbox. Vertical alignmenttcolorbox version 3 top alignmenttcolorbox vertical alignmentAlignment problem with title in rather complex tcolorbox












0















Consider the following test code:



% ---------------------------------------------------------------------------- %
% File
begin{filecontents*}{jobname.cpp}
0000
0000
end{filecontents*}
begin{filecontents*}{multijobname.cpp}
0000
0000
0000
0000
end{filecontents*}
% ---------------------------------------------------------------------------- %
% Preamble
documentclass[letterpaper, 12pt, onecolumn]{article}
% ---------------------------------------------------------------------------- %
% Packages
usepackage{xcolor}
usepackage{listings}
usepackage{multicol}
usepackage[most]{tcolorbox}
% ---------------------------------------------------------------------------- %
% Listings options
definecolor{grey}{RGB}{224, 224, 224}
newtcbinputlisting{inputcode}[4][normalsize]{
code = {},
enhanced,
listing only,
top = 0pt,
bottom = 0pt,
left = 0pt,
right = 0pt,
arc = 0pt,
outer arc = 0pt,
boxsep = 0pt,
titlerule = 0pt,
colback = grey,
colframe = black,
boxrule = 2pt,
title = {centering{fontfamily{cmtt}selectfont#2strut}},
listing options = {
language = C++,
framesep = 0pt,
rulesep = 0pt,
aboveskip = 0pt,
belowskip = 0pt,
basicstyle = fontfamily{cmtt}selectfont#1,
#3,
},
listing file={#4},
}
% ---------------------------------------------------------------------------- %
% Commands
newcommand{alphabet}{%
small{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}%
}
newcommand{makelisting}[2]{%
newpage%
noindentalphabet%
inputcode[#1]{#2}{}{jobname.cpp}%
noindentalphabet%
inputcode[#1]{#2}{multicols = 2}{multijobname.cpp}%
noindentalphabet%
}
% ---------------------------------------------------------------------------- %
% Document
begin{document}
makelisting{tiny}{tiny}
makelisting{scriptsize}{scriptsize}
makelisting{footnotesize}{footnotesize}
makelisting{small}{small}
makelisting{normalsize}{normalsize}
makelisting{large}{large}
makelisting{Large}{Large}
makelisting{LARGE}{LARGE}
makelisting{huge}{huge}
makelisting{Huge}{Huge}
end{document}
% ---------------------------------------------------------------------------- %


It produces pairs of listings in tcolorboxes: one without multicolumn and the other with multicolumn. Examples of the output:





tiny





Huge





On these images:




  • the distance between the top of the listing and the top of the first line corresponds to the red arrows

  • the distance between the bottom of the listing and the bottom of the last line corresponds to the blue arrows


As show, the multicols option changes these distances. The change seems affected by the size of the font in the listing (as well as the size of normalsize specified in the document class).



How to correct the vertical spacing so that the spacing of the multicols version corresponds to the spacing without the multicols? (in a generic manner that would work for all font sizes)










share|improve this question





























    0















    Consider the following test code:



    % ---------------------------------------------------------------------------- %
    % File
    begin{filecontents*}{jobname.cpp}
    0000
    0000
    end{filecontents*}
    begin{filecontents*}{multijobname.cpp}
    0000
    0000
    0000
    0000
    end{filecontents*}
    % ---------------------------------------------------------------------------- %
    % Preamble
    documentclass[letterpaper, 12pt, onecolumn]{article}
    % ---------------------------------------------------------------------------- %
    % Packages
    usepackage{xcolor}
    usepackage{listings}
    usepackage{multicol}
    usepackage[most]{tcolorbox}
    % ---------------------------------------------------------------------------- %
    % Listings options
    definecolor{grey}{RGB}{224, 224, 224}
    newtcbinputlisting{inputcode}[4][normalsize]{
    code = {},
    enhanced,
    listing only,
    top = 0pt,
    bottom = 0pt,
    left = 0pt,
    right = 0pt,
    arc = 0pt,
    outer arc = 0pt,
    boxsep = 0pt,
    titlerule = 0pt,
    colback = grey,
    colframe = black,
    boxrule = 2pt,
    title = {centering{fontfamily{cmtt}selectfont#2strut}},
    listing options = {
    language = C++,
    framesep = 0pt,
    rulesep = 0pt,
    aboveskip = 0pt,
    belowskip = 0pt,
    basicstyle = fontfamily{cmtt}selectfont#1,
    #3,
    },
    listing file={#4},
    }
    % ---------------------------------------------------------------------------- %
    % Commands
    newcommand{alphabet}{%
    small{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}%
    }
    newcommand{makelisting}[2]{%
    newpage%
    noindentalphabet%
    inputcode[#1]{#2}{}{jobname.cpp}%
    noindentalphabet%
    inputcode[#1]{#2}{multicols = 2}{multijobname.cpp}%
    noindentalphabet%
    }
    % ---------------------------------------------------------------------------- %
    % Document
    begin{document}
    makelisting{tiny}{tiny}
    makelisting{scriptsize}{scriptsize}
    makelisting{footnotesize}{footnotesize}
    makelisting{small}{small}
    makelisting{normalsize}{normalsize}
    makelisting{large}{large}
    makelisting{Large}{Large}
    makelisting{LARGE}{LARGE}
    makelisting{huge}{huge}
    makelisting{Huge}{Huge}
    end{document}
    % ---------------------------------------------------------------------------- %


    It produces pairs of listings in tcolorboxes: one without multicolumn and the other with multicolumn. Examples of the output:





    tiny





    Huge





    On these images:




    • the distance between the top of the listing and the top of the first line corresponds to the red arrows

    • the distance between the bottom of the listing and the bottom of the last line corresponds to the blue arrows


    As show, the multicols option changes these distances. The change seems affected by the size of the font in the listing (as well as the size of normalsize specified in the document class).



    How to correct the vertical spacing so that the spacing of the multicols version corresponds to the spacing without the multicols? (in a generic manner that would work for all font sizes)










    share|improve this question



























      0












      0








      0


      2






      Consider the following test code:



      % ---------------------------------------------------------------------------- %
      % File
      begin{filecontents*}{jobname.cpp}
      0000
      0000
      end{filecontents*}
      begin{filecontents*}{multijobname.cpp}
      0000
      0000
      0000
      0000
      end{filecontents*}
      % ---------------------------------------------------------------------------- %
      % Preamble
      documentclass[letterpaper, 12pt, onecolumn]{article}
      % ---------------------------------------------------------------------------- %
      % Packages
      usepackage{xcolor}
      usepackage{listings}
      usepackage{multicol}
      usepackage[most]{tcolorbox}
      % ---------------------------------------------------------------------------- %
      % Listings options
      definecolor{grey}{RGB}{224, 224, 224}
      newtcbinputlisting{inputcode}[4][normalsize]{
      code = {},
      enhanced,
      listing only,
      top = 0pt,
      bottom = 0pt,
      left = 0pt,
      right = 0pt,
      arc = 0pt,
      outer arc = 0pt,
      boxsep = 0pt,
      titlerule = 0pt,
      colback = grey,
      colframe = black,
      boxrule = 2pt,
      title = {centering{fontfamily{cmtt}selectfont#2strut}},
      listing options = {
      language = C++,
      framesep = 0pt,
      rulesep = 0pt,
      aboveskip = 0pt,
      belowskip = 0pt,
      basicstyle = fontfamily{cmtt}selectfont#1,
      #3,
      },
      listing file={#4},
      }
      % ---------------------------------------------------------------------------- %
      % Commands
      newcommand{alphabet}{%
      small{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}%
      }
      newcommand{makelisting}[2]{%
      newpage%
      noindentalphabet%
      inputcode[#1]{#2}{}{jobname.cpp}%
      noindentalphabet%
      inputcode[#1]{#2}{multicols = 2}{multijobname.cpp}%
      noindentalphabet%
      }
      % ---------------------------------------------------------------------------- %
      % Document
      begin{document}
      makelisting{tiny}{tiny}
      makelisting{scriptsize}{scriptsize}
      makelisting{footnotesize}{footnotesize}
      makelisting{small}{small}
      makelisting{normalsize}{normalsize}
      makelisting{large}{large}
      makelisting{Large}{Large}
      makelisting{LARGE}{LARGE}
      makelisting{huge}{huge}
      makelisting{Huge}{Huge}
      end{document}
      % ---------------------------------------------------------------------------- %


      It produces pairs of listings in tcolorboxes: one without multicolumn and the other with multicolumn. Examples of the output:





      tiny





      Huge





      On these images:




      • the distance between the top of the listing and the top of the first line corresponds to the red arrows

      • the distance between the bottom of the listing and the bottom of the last line corresponds to the blue arrows


      As show, the multicols option changes these distances. The change seems affected by the size of the font in the listing (as well as the size of normalsize specified in the document class).



      How to correct the vertical spacing so that the spacing of the multicols version corresponds to the spacing without the multicols? (in a generic manner that would work for all font sizes)










      share|improve this question
















      Consider the following test code:



      % ---------------------------------------------------------------------------- %
      % File
      begin{filecontents*}{jobname.cpp}
      0000
      0000
      end{filecontents*}
      begin{filecontents*}{multijobname.cpp}
      0000
      0000
      0000
      0000
      end{filecontents*}
      % ---------------------------------------------------------------------------- %
      % Preamble
      documentclass[letterpaper, 12pt, onecolumn]{article}
      % ---------------------------------------------------------------------------- %
      % Packages
      usepackage{xcolor}
      usepackage{listings}
      usepackage{multicol}
      usepackage[most]{tcolorbox}
      % ---------------------------------------------------------------------------- %
      % Listings options
      definecolor{grey}{RGB}{224, 224, 224}
      newtcbinputlisting{inputcode}[4][normalsize]{
      code = {},
      enhanced,
      listing only,
      top = 0pt,
      bottom = 0pt,
      left = 0pt,
      right = 0pt,
      arc = 0pt,
      outer arc = 0pt,
      boxsep = 0pt,
      titlerule = 0pt,
      colback = grey,
      colframe = black,
      boxrule = 2pt,
      title = {centering{fontfamily{cmtt}selectfont#2strut}},
      listing options = {
      language = C++,
      framesep = 0pt,
      rulesep = 0pt,
      aboveskip = 0pt,
      belowskip = 0pt,
      basicstyle = fontfamily{cmtt}selectfont#1,
      #3,
      },
      listing file={#4},
      }
      % ---------------------------------------------------------------------------- %
      % Commands
      newcommand{alphabet}{%
      small{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}%
      }
      newcommand{makelisting}[2]{%
      newpage%
      noindentalphabet%
      inputcode[#1]{#2}{}{jobname.cpp}%
      noindentalphabet%
      inputcode[#1]{#2}{multicols = 2}{multijobname.cpp}%
      noindentalphabet%
      }
      % ---------------------------------------------------------------------------- %
      % Document
      begin{document}
      makelisting{tiny}{tiny}
      makelisting{scriptsize}{scriptsize}
      makelisting{footnotesize}{footnotesize}
      makelisting{small}{small}
      makelisting{normalsize}{normalsize}
      makelisting{large}{large}
      makelisting{Large}{Large}
      makelisting{LARGE}{LARGE}
      makelisting{huge}{huge}
      makelisting{Huge}{Huge}
      end{document}
      % ---------------------------------------------------------------------------- %


      It produces pairs of listings in tcolorboxes: one without multicolumn and the other with multicolumn. Examples of the output:





      tiny





      Huge





      On these images:




      • the distance between the top of the listing and the top of the first line corresponds to the red arrows

      • the distance between the bottom of the listing and the bottom of the last line corresponds to the blue arrows


      As show, the multicols option changes these distances. The change seems affected by the size of the font in the listing (as well as the size of normalsize specified in the document class).



      How to correct the vertical spacing so that the spacing of the multicols version corresponds to the spacing without the multicols? (in a generic manner that would work for all font sizes)







      spacing vertical-alignment listings tcolorbox multicol






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 mins ago







      Vincent

















      asked 13 hours ago









      VincentVincent

      1,76221939




      1,76221939






















          0






          active

          oldest

          votes












          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%2f487356%2fproblem-with-vertical-alignment-of-a-multicolumn-listing-in-a-tcolorbox%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f487356%2fproblem-with-vertical-alignment-of-a-multicolumn-listing-in-a-tcolorbox%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...

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

          Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...