How to decrease the line spaces in listing codes?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I want to decrease the line spaces of the java codes in the following latex. I already used setstretch0.4 but it seems that this code does not work for listing contents. how should I do this??



beginfilecontents*FristProgram.java
import java.io.*;
class ShowFile


endfilecontents*

documentclass[svgnames]report
usepackagetikz
usepackageverbatim
usepackagekpfonts
usepackage[explicit]titlesec
usetikzlibrarycalc
usetikzlibraryshadows
usetikzlibraryshadows.blur
usetikzlibrarymatrix
usetikzlibraryshapes,snakes
usetikzlibraryshapes.geometric, arrows
usepackagelistings
usepackageshowframe

definecolorcodegreenrgb0,0,0
definecolorcodegrayrgb0,0,0
definecolorcodepurplergb0,0,0
%definecolorbackcolourrgb0.95,0.95,0.92
definecolorbackcolourrgb1,1,1
lstdefinestylemystyle
backgroundcolor=colorbackcolour,
commentstyle=colorcodegreen,
numberstyle=tinycolorcodegray,
stringstyle=colorcodepurple,
basicstyle=normalsizettfamily,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=none,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
lineskip=.1cm




lstsetstyle=mystyle

begindocument
tikzstyleContainer = [draw=none, fill=gray, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
tikzstyleProgramBox = [draw=black, fill=white,thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black
]

tikzstyleExampleBox = [draw=black, fill=white, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black]

centering
begintikzpicture
labelnum
node [Container](container)
begintikzpicture
node [ProgramBox] (pbox)%
beginminipagedimexprtextwidth-40ptrelax
hrule width hsize height 1pt


lstinputlisting[language=Java]FristProgram.java
hrule width hsize kern 1mm hrule width hsize height 1pt

endminipage
;
endtikzpicture
;
node [ExampleBox, anchor=north west] at (container.south west)
beginminipage0.3textwidth
this\
is \
the \
first \
example
endminipage
;

node [ExampleBox, anchor=north east] at (container.south east)
beginminipage0.3textwidth
this\
is \
the \
second \
example \
which \
is \
larger\
than \
first\
example
endminipage
;
endtikzpicture%
par

enddocument









share|improve this question







New contributor




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



















  • I'm not sure what you mean by that. If you try and set the “second example” with ttfamily and the same text as the “first example”, you'll see that the heights are essentially the same. You can try basicstyle=linespread0.9normalfontttfamily, if you so prefer.
    – egreg
    1 hour ago














up vote
2
down vote

favorite












I want to decrease the line spaces of the java codes in the following latex. I already used setstretch0.4 but it seems that this code does not work for listing contents. how should I do this??



beginfilecontents*FristProgram.java
import java.io.*;
class ShowFile


endfilecontents*

documentclass[svgnames]report
usepackagetikz
usepackageverbatim
usepackagekpfonts
usepackage[explicit]titlesec
usetikzlibrarycalc
usetikzlibraryshadows
usetikzlibraryshadows.blur
usetikzlibrarymatrix
usetikzlibraryshapes,snakes
usetikzlibraryshapes.geometric, arrows
usepackagelistings
usepackageshowframe

definecolorcodegreenrgb0,0,0
definecolorcodegrayrgb0,0,0
definecolorcodepurplergb0,0,0
%definecolorbackcolourrgb0.95,0.95,0.92
definecolorbackcolourrgb1,1,1
lstdefinestylemystyle
backgroundcolor=colorbackcolour,
commentstyle=colorcodegreen,
numberstyle=tinycolorcodegray,
stringstyle=colorcodepurple,
basicstyle=normalsizettfamily,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=none,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
lineskip=.1cm




lstsetstyle=mystyle

begindocument
tikzstyleContainer = [draw=none, fill=gray, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
tikzstyleProgramBox = [draw=black, fill=white,thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black
]

tikzstyleExampleBox = [draw=black, fill=white, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black]

centering
begintikzpicture
labelnum
node [Container](container)
begintikzpicture
node [ProgramBox] (pbox)%
beginminipagedimexprtextwidth-40ptrelax
hrule width hsize height 1pt


lstinputlisting[language=Java]FristProgram.java
hrule width hsize kern 1mm hrule width hsize height 1pt

endminipage
;
endtikzpicture
;
node [ExampleBox, anchor=north west] at (container.south west)
beginminipage0.3textwidth
this\
is \
the \
first \
example
endminipage
;

node [ExampleBox, anchor=north east] at (container.south east)
beginminipage0.3textwidth
this\
is \
the \
second \
example \
which \
is \
larger\
than \
first\
example
endminipage
;
endtikzpicture%
par

enddocument









share|improve this question







New contributor




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



















  • I'm not sure what you mean by that. If you try and set the “second example” with ttfamily and the same text as the “first example”, you'll see that the heights are essentially the same. You can try basicstyle=linespread0.9normalfontttfamily, if you so prefer.
    – egreg
    1 hour ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I want to decrease the line spaces of the java codes in the following latex. I already used setstretch0.4 but it seems that this code does not work for listing contents. how should I do this??



beginfilecontents*FristProgram.java
import java.io.*;
class ShowFile


endfilecontents*

documentclass[svgnames]report
usepackagetikz
usepackageverbatim
usepackagekpfonts
usepackage[explicit]titlesec
usetikzlibrarycalc
usetikzlibraryshadows
usetikzlibraryshadows.blur
usetikzlibrarymatrix
usetikzlibraryshapes,snakes
usetikzlibraryshapes.geometric, arrows
usepackagelistings
usepackageshowframe

definecolorcodegreenrgb0,0,0
definecolorcodegrayrgb0,0,0
definecolorcodepurplergb0,0,0
%definecolorbackcolourrgb0.95,0.95,0.92
definecolorbackcolourrgb1,1,1
lstdefinestylemystyle
backgroundcolor=colorbackcolour,
commentstyle=colorcodegreen,
numberstyle=tinycolorcodegray,
stringstyle=colorcodepurple,
basicstyle=normalsizettfamily,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=none,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
lineskip=.1cm




lstsetstyle=mystyle

begindocument
tikzstyleContainer = [draw=none, fill=gray, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
tikzstyleProgramBox = [draw=black, fill=white,thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black
]

tikzstyleExampleBox = [draw=black, fill=white, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black]

centering
begintikzpicture
labelnum
node [Container](container)
begintikzpicture
node [ProgramBox] (pbox)%
beginminipagedimexprtextwidth-40ptrelax
hrule width hsize height 1pt


lstinputlisting[language=Java]FristProgram.java
hrule width hsize kern 1mm hrule width hsize height 1pt

endminipage
;
endtikzpicture
;
node [ExampleBox, anchor=north west] at (container.south west)
beginminipage0.3textwidth
this\
is \
the \
first \
example
endminipage
;

node [ExampleBox, anchor=north east] at (container.south east)
beginminipage0.3textwidth
this\
is \
the \
second \
example \
which \
is \
larger\
than \
first\
example
endminipage
;
endtikzpicture%
par

enddocument









share|improve this question







New contributor




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











I want to decrease the line spaces of the java codes in the following latex. I already used setstretch0.4 but it seems that this code does not work for listing contents. how should I do this??



beginfilecontents*FristProgram.java
import java.io.*;
class ShowFile


endfilecontents*

documentclass[svgnames]report
usepackagetikz
usepackageverbatim
usepackagekpfonts
usepackage[explicit]titlesec
usetikzlibrarycalc
usetikzlibraryshadows
usetikzlibraryshadows.blur
usetikzlibrarymatrix
usetikzlibraryshapes,snakes
usetikzlibraryshapes.geometric, arrows
usepackagelistings
usepackageshowframe

definecolorcodegreenrgb0,0,0
definecolorcodegrayrgb0,0,0
definecolorcodepurplergb0,0,0
%definecolorbackcolourrgb0.95,0.95,0.92
definecolorbackcolourrgb1,1,1
lstdefinestylemystyle
backgroundcolor=colorbackcolour,
commentstyle=colorcodegreen,
numberstyle=tinycolorcodegray,
stringstyle=colorcodepurple,
basicstyle=normalsizettfamily,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=none,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4,
lineskip=.1cm




lstsetstyle=mystyle

begindocument
tikzstyleContainer = [draw=none, fill=gray, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
tikzstyleProgramBox = [draw=black, fill=white,thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black
]

tikzstyleExampleBox = [draw=black, fill=white, thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt,drop shadow=color=black]

centering
begintikzpicture
labelnum
node [Container](container)
begintikzpicture
node [ProgramBox] (pbox)%
beginminipagedimexprtextwidth-40ptrelax
hrule width hsize height 1pt


lstinputlisting[language=Java]FristProgram.java
hrule width hsize kern 1mm hrule width hsize height 1pt

endminipage
;
endtikzpicture
;
node [ExampleBox, anchor=north west] at (container.south west)
beginminipage0.3textwidth
this\
is \
the \
first \
example
endminipage
;

node [ExampleBox, anchor=north east] at (container.south east)
beginminipage0.3textwidth
this\
is \
the \
second \
example \
which \
is \
larger\
than \
first\
example
endminipage
;
endtikzpicture%
par

enddocument






listings minipage






share|improve this question







New contributor




Sadegh Eskandari 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




Sadegh Eskandari 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




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









asked 2 hours ago









Sadegh Eskandari

282




282




New contributor




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





New contributor





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






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











  • I'm not sure what you mean by that. If you try and set the “second example” with ttfamily and the same text as the “first example”, you'll see that the heights are essentially the same. You can try basicstyle=linespread0.9normalfontttfamily, if you so prefer.
    – egreg
    1 hour ago
















  • I'm not sure what you mean by that. If you try and set the “second example” with ttfamily and the same text as the “first example”, you'll see that the heights are essentially the same. You can try basicstyle=linespread0.9normalfontttfamily, if you so prefer.
    – egreg
    1 hour ago















I'm not sure what you mean by that. If you try and set the “second example” with ttfamily and the same text as the “first example”, you'll see that the heights are essentially the same. You can try basicstyle=linespread0.9normalfontttfamily, if you so prefer.
– egreg
1 hour ago




I'm not sure what you mean by that. If you try and set the “second example” with ttfamily and the same text as the “first example”, you'll see that the heights are essentially the same. You can try basicstyle=linespread0.9normalfontttfamily, if you so prefer.
– egreg
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote













The lineskip= parameter in your lstdefinestyle controls this. Try changing it to lineskip=-.1cm, for example:



enter image description here



With the original setting, lineskip=.1cm, it gives this:



enter image description here






share|improve this answer



























    up vote
    1
    down vote













    just show, that Steven B. Segletes's solution also work with my answer on your previous question:



    beginfilecontents*FristProgram.java
    import java.io.*;
    class ShowFile


    endfilecontents*

    documentclass[svgnames]report
    usepackagetikz
    usetikzlibraryarrows,
    backgrounds,
    fit,
    positioning,
    shadows
    usepackagelistings
    usepackagegraphicx

    definecolorcodegreenrgb0,0,0
    definecolorcodegrayrgb0,0,0
    definecolorcodepurplergb0,0,0
    %definecolorbackcolourrgb0.95,0.95,0.92
    definecolorbackcolourrgb1,1,1
    lstdefinestylemystyle
    backgroundcolor=colorbackcolour,
    commentstyle=colorcodegreen,
    numberstyle=tinycolorcodegray,
    stringstyle=colorcodepurple,
    basicstyle=normalsizettfamily,
    breakatwhitespace=false,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=none,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=4,
    lineskip=-2ex % <---




    lstsetstyle=mystyle
    begindocument

    begincenter
    begintikzpicture[
    node distance = 8pt and 24pt,
    box/.style = rectangle, rounded corners, draw, thick, fill=white,
    text width=#1, inner xsep=10pt, inner ysep=20pt,
    drop shadow=color=black
    ,
    container/.style = rectangle, rounded corners, fill=gray,
    text width=linewidth, inner xsep=10pt, inner ysep=20pt

    ]
    %labelnum
    node [box=0.95linewidth,align=center] (list)

    hrule width hsize height 1pt
    lstinputlisting[language=Java]FristProgram.java
    hrule width hsize kern 1mm
    hrule width hsize height 1pt
    ;
    scoped[on background layer]
    node [container, fit=(list)] ;
    %labelnum
    node [box=0.3linewidth, below right=of list.south west]
    this\
    is \
    the \
    first \
    example;
    node [box=0.3linewidth,below left=of list.south east]
    this\
    is \
    the \
    second \
    example \
    which \
    is \
    larger\
    than \
    first\
    example;
    endtikzpicture%
    endcenter
    enddocument


    enter image description here






    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',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Sadegh Eskandari 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%2f451510%2fhow-to-decrease-the-line-spaces-in-listing-codes%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      The lineskip= parameter in your lstdefinestyle controls this. Try changing it to lineskip=-.1cm, for example:



      enter image description here



      With the original setting, lineskip=.1cm, it gives this:



      enter image description here






      share|improve this answer
























        up vote
        2
        down vote













        The lineskip= parameter in your lstdefinestyle controls this. Try changing it to lineskip=-.1cm, for example:



        enter image description here



        With the original setting, lineskip=.1cm, it gives this:



        enter image description here






        share|improve this answer






















          up vote
          2
          down vote










          up vote
          2
          down vote









          The lineskip= parameter in your lstdefinestyle controls this. Try changing it to lineskip=-.1cm, for example:



          enter image description here



          With the original setting, lineskip=.1cm, it gives this:



          enter image description here






          share|improve this answer












          The lineskip= parameter in your lstdefinestyle controls this. Try changing it to lineskip=-.1cm, for example:



          enter image description here



          With the original setting, lineskip=.1cm, it gives this:



          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          Steven B. Segletes

          147k9186388




          147k9186388




















              up vote
              1
              down vote













              just show, that Steven B. Segletes's solution also work with my answer on your previous question:



              beginfilecontents*FristProgram.java
              import java.io.*;
              class ShowFile


              endfilecontents*

              documentclass[svgnames]report
              usepackagetikz
              usetikzlibraryarrows,
              backgrounds,
              fit,
              positioning,
              shadows
              usepackagelistings
              usepackagegraphicx

              definecolorcodegreenrgb0,0,0
              definecolorcodegrayrgb0,0,0
              definecolorcodepurplergb0,0,0
              %definecolorbackcolourrgb0.95,0.95,0.92
              definecolorbackcolourrgb1,1,1
              lstdefinestylemystyle
              backgroundcolor=colorbackcolour,
              commentstyle=colorcodegreen,
              numberstyle=tinycolorcodegray,
              stringstyle=colorcodepurple,
              basicstyle=normalsizettfamily,
              breakatwhitespace=false,
              breaklines=true,
              captionpos=b,
              keepspaces=true,
              numbers=none,
              numbersep=5pt,
              showspaces=false,
              showstringspaces=false,
              showtabs=false,
              tabsize=4,
              lineskip=-2ex % <---




              lstsetstyle=mystyle
              begindocument

              begincenter
              begintikzpicture[
              node distance = 8pt and 24pt,
              box/.style = rectangle, rounded corners, draw, thick, fill=white,
              text width=#1, inner xsep=10pt, inner ysep=20pt,
              drop shadow=color=black
              ,
              container/.style = rectangle, rounded corners, fill=gray,
              text width=linewidth, inner xsep=10pt, inner ysep=20pt

              ]
              %labelnum
              node [box=0.95linewidth,align=center] (list)

              hrule width hsize height 1pt
              lstinputlisting[language=Java]FristProgram.java
              hrule width hsize kern 1mm
              hrule width hsize height 1pt
              ;
              scoped[on background layer]
              node [container, fit=(list)] ;
              %labelnum
              node [box=0.3linewidth, below right=of list.south west]
              this\
              is \
              the \
              first \
              example;
              node [box=0.3linewidth,below left=of list.south east]
              this\
              is \
              the \
              second \
              example \
              which \
              is \
              larger\
              than \
              first\
              example;
              endtikzpicture%
              endcenter
              enddocument


              enter image description here






              share|improve this answer
























                up vote
                1
                down vote













                just show, that Steven B. Segletes's solution also work with my answer on your previous question:



                beginfilecontents*FristProgram.java
                import java.io.*;
                class ShowFile


                endfilecontents*

                documentclass[svgnames]report
                usepackagetikz
                usetikzlibraryarrows,
                backgrounds,
                fit,
                positioning,
                shadows
                usepackagelistings
                usepackagegraphicx

                definecolorcodegreenrgb0,0,0
                definecolorcodegrayrgb0,0,0
                definecolorcodepurplergb0,0,0
                %definecolorbackcolourrgb0.95,0.95,0.92
                definecolorbackcolourrgb1,1,1
                lstdefinestylemystyle
                backgroundcolor=colorbackcolour,
                commentstyle=colorcodegreen,
                numberstyle=tinycolorcodegray,
                stringstyle=colorcodepurple,
                basicstyle=normalsizettfamily,
                breakatwhitespace=false,
                breaklines=true,
                captionpos=b,
                keepspaces=true,
                numbers=none,
                numbersep=5pt,
                showspaces=false,
                showstringspaces=false,
                showtabs=false,
                tabsize=4,
                lineskip=-2ex % <---




                lstsetstyle=mystyle
                begindocument

                begincenter
                begintikzpicture[
                node distance = 8pt and 24pt,
                box/.style = rectangle, rounded corners, draw, thick, fill=white,
                text width=#1, inner xsep=10pt, inner ysep=20pt,
                drop shadow=color=black
                ,
                container/.style = rectangle, rounded corners, fill=gray,
                text width=linewidth, inner xsep=10pt, inner ysep=20pt

                ]
                %labelnum
                node [box=0.95linewidth,align=center] (list)

                hrule width hsize height 1pt
                lstinputlisting[language=Java]FristProgram.java
                hrule width hsize kern 1mm
                hrule width hsize height 1pt
                ;
                scoped[on background layer]
                node [container, fit=(list)] ;
                %labelnum
                node [box=0.3linewidth, below right=of list.south west]
                this\
                is \
                the \
                first \
                example;
                node [box=0.3linewidth,below left=of list.south east]
                this\
                is \
                the \
                second \
                example \
                which \
                is \
                larger\
                than \
                first\
                example;
                endtikzpicture%
                endcenter
                enddocument


                enter image description here






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  just show, that Steven B. Segletes's solution also work with my answer on your previous question:



                  beginfilecontents*FristProgram.java
                  import java.io.*;
                  class ShowFile


                  endfilecontents*

                  documentclass[svgnames]report
                  usepackagetikz
                  usetikzlibraryarrows,
                  backgrounds,
                  fit,
                  positioning,
                  shadows
                  usepackagelistings
                  usepackagegraphicx

                  definecolorcodegreenrgb0,0,0
                  definecolorcodegrayrgb0,0,0
                  definecolorcodepurplergb0,0,0
                  %definecolorbackcolourrgb0.95,0.95,0.92
                  definecolorbackcolourrgb1,1,1
                  lstdefinestylemystyle
                  backgroundcolor=colorbackcolour,
                  commentstyle=colorcodegreen,
                  numberstyle=tinycolorcodegray,
                  stringstyle=colorcodepurple,
                  basicstyle=normalsizettfamily,
                  breakatwhitespace=false,
                  breaklines=true,
                  captionpos=b,
                  keepspaces=true,
                  numbers=none,
                  numbersep=5pt,
                  showspaces=false,
                  showstringspaces=false,
                  showtabs=false,
                  tabsize=4,
                  lineskip=-2ex % <---




                  lstsetstyle=mystyle
                  begindocument

                  begincenter
                  begintikzpicture[
                  node distance = 8pt and 24pt,
                  box/.style = rectangle, rounded corners, draw, thick, fill=white,
                  text width=#1, inner xsep=10pt, inner ysep=20pt,
                  drop shadow=color=black
                  ,
                  container/.style = rectangle, rounded corners, fill=gray,
                  text width=linewidth, inner xsep=10pt, inner ysep=20pt

                  ]
                  %labelnum
                  node [box=0.95linewidth,align=center] (list)

                  hrule width hsize height 1pt
                  lstinputlisting[language=Java]FristProgram.java
                  hrule width hsize kern 1mm
                  hrule width hsize height 1pt
                  ;
                  scoped[on background layer]
                  node [container, fit=(list)] ;
                  %labelnum
                  node [box=0.3linewidth, below right=of list.south west]
                  this\
                  is \
                  the \
                  first \
                  example;
                  node [box=0.3linewidth,below left=of list.south east]
                  this\
                  is \
                  the \
                  second \
                  example \
                  which \
                  is \
                  larger\
                  than \
                  first\
                  example;
                  endtikzpicture%
                  endcenter
                  enddocument


                  enter image description here






                  share|improve this answer












                  just show, that Steven B. Segletes's solution also work with my answer on your previous question:



                  beginfilecontents*FristProgram.java
                  import java.io.*;
                  class ShowFile


                  endfilecontents*

                  documentclass[svgnames]report
                  usepackagetikz
                  usetikzlibraryarrows,
                  backgrounds,
                  fit,
                  positioning,
                  shadows
                  usepackagelistings
                  usepackagegraphicx

                  definecolorcodegreenrgb0,0,0
                  definecolorcodegrayrgb0,0,0
                  definecolorcodepurplergb0,0,0
                  %definecolorbackcolourrgb0.95,0.95,0.92
                  definecolorbackcolourrgb1,1,1
                  lstdefinestylemystyle
                  backgroundcolor=colorbackcolour,
                  commentstyle=colorcodegreen,
                  numberstyle=tinycolorcodegray,
                  stringstyle=colorcodepurple,
                  basicstyle=normalsizettfamily,
                  breakatwhitespace=false,
                  breaklines=true,
                  captionpos=b,
                  keepspaces=true,
                  numbers=none,
                  numbersep=5pt,
                  showspaces=false,
                  showstringspaces=false,
                  showtabs=false,
                  tabsize=4,
                  lineskip=-2ex % <---




                  lstsetstyle=mystyle
                  begindocument

                  begincenter
                  begintikzpicture[
                  node distance = 8pt and 24pt,
                  box/.style = rectangle, rounded corners, draw, thick, fill=white,
                  text width=#1, inner xsep=10pt, inner ysep=20pt,
                  drop shadow=color=black
                  ,
                  container/.style = rectangle, rounded corners, fill=gray,
                  text width=linewidth, inner xsep=10pt, inner ysep=20pt

                  ]
                  %labelnum
                  node [box=0.95linewidth,align=center] (list)

                  hrule width hsize height 1pt
                  lstinputlisting[language=Java]FristProgram.java
                  hrule width hsize kern 1mm
                  hrule width hsize height 1pt
                  ;
                  scoped[on background layer]
                  node [container, fit=(list)] ;
                  %labelnum
                  node [box=0.3linewidth, below right=of list.south west]
                  this\
                  is \
                  the \
                  first \
                  example;
                  node [box=0.3linewidth,below left=of list.south east]
                  this\
                  is \
                  the \
                  second \
                  example \
                  which \
                  is \
                  larger\
                  than \
                  first\
                  example;
                  endtikzpicture%
                  endcenter
                  enddocument


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 22 mins ago









                  Zarko

                  113k861150




                  113k861150




















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









                       

                      draft saved


                      draft discarded


















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












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











                      Sadegh Eskandari 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%2f451510%2fhow-to-decrease-the-line-spaces-in-listing-codes%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery