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
4
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





















  • 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
    Sep 19 at 10:56














up vote
4
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





















  • 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
    Sep 19 at 10:56












up vote
4
down vote

favorite









up vote
4
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













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













share|improve this question











share|improve this question




share|improve this question










asked Sep 19 at 9:55









Sadegh Eskandari

383




383











  • 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
    Sep 19 at 10:56
















  • 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
    Sep 19 at 10:56















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
Sep 19 at 10:56




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
Sep 19 at 10:56










2 Answers
2






active

oldest

votes

















up vote
4
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
    3
    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
      );



      );













       

      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
      4
      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
        4
        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
          4
          down vote










          up vote
          4
          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 Sep 19 at 10:14









          Steven B. Segletes

          148k9186390




          148k9186390




















              up vote
              3
              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
                3
                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
                  3
                  down vote










                  up vote
                  3
                  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 Sep 19 at 12:30









                  Zarko

                  114k863152




                  114k863152



























                       

                      draft saved


                      draft discarded















































                       


                      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













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay