The inserted code has extra blank lines











up vote
0
down vote

favorite












I'm using listings to format blocks of code in my xeLaTeX.When I insert this picture into Anki's card, the inserted code has extra blank lines. Following is my MWE:



documentclass{standalone} 
usepackage{tcolorbox,listings}
usepackage{fontspec}
setmonofont{Consolas}
usepackage{color}
usepackage{tikz}
usepackage{framed}

definecolor{background}{HTML}{EEEEEE}
definecolor{comments}{HTML}{868686}
definecolor{darkred}{RGB}{139,0,0}
definecolor{darkblue}{RGB}{0,0,139}
definecolor{chartreuse}{RGB}{127,255,0}
definecolor{drakgreen}{RGB}{0,128,0}
definecolor{lightgray}{RGB}{238,239,240}


lstset{
language=[LaTeX]Tex,
keywordstyle=color{darkblue},
texcsstyle=*color{blue},
basicstyle=normalfontttfamily,
commentstyle=color{comments}ttfamily,
stringstyle=rmfamily,
numbers=none,
numberstyle=scriptsize,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frameround=ftff,
frame=single,
captionpos=t,
belowcaptionskip=0em,
belowskip=0em,

literate=
*{{}{{textcolor{darkred}{{}}}{1}
{}}{{textcolor{darkred}{}}}}{1}
{[}{{textcolor{darkred}{[}}}{1}
{]}{{textcolor{darkred}{]}}}{1},
}
lstdefinestyle{mystyle}{
language=[LaTeX]Tex,
extendedchars=true,
breaklines=true,
breakatwhitespace=true,
basicstyle=ttfamily,
numbers=none,
keywordstyle=color{darkblue},
keywordstyle=[2]color{blue},
keywordstyle=[3]color{darkblue},
keywordstyle=[4]color{drakgreen},
alsoletter = {!},
keywords=[2]{definecolor,node,addplot},
keywords=[3]{usepackage},
keywords=[4]{begin,end,document,figure,figure*,axis}
}

tcbuselibrary{listings,skins,breakable}
newtcblisting{code}{
arc=0mm,
top=0mm,
bottom=0mm,
left=3mm,
right=0mm,
width=textwidth,
boxrule=1pt,
colback=lightgray,
listing only,
listing options={style=mystyle},
breakable
}

begin{document}

begin{code}
begin{tikzpicture}
filldraw [gray] (0,0) circle (2pt)
(1,1) circle (2pt)
(2,1) circle (2pt)
(2,0) circle (2pt);
draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
end{tikzpicture}
end{code}
[/latex]
When executed, that is, run via pdflatex or via latex followed by dvips, the resulting will contain something that looks like this:

We are working on
begin{tikzpicture}
draw (-1.5,0) -- (1.5,0);
draw (0,-1.5) -- (0,1.5);
end{tikzpicture}.

begin{document}


enter image description here



How to eliminate the extra blank lines at the top?









share


























    up vote
    0
    down vote

    favorite












    I'm using listings to format blocks of code in my xeLaTeX.When I insert this picture into Anki's card, the inserted code has extra blank lines. Following is my MWE:



    documentclass{standalone} 
    usepackage{tcolorbox,listings}
    usepackage{fontspec}
    setmonofont{Consolas}
    usepackage{color}
    usepackage{tikz}
    usepackage{framed}

    definecolor{background}{HTML}{EEEEEE}
    definecolor{comments}{HTML}{868686}
    definecolor{darkred}{RGB}{139,0,0}
    definecolor{darkblue}{RGB}{0,0,139}
    definecolor{chartreuse}{RGB}{127,255,0}
    definecolor{drakgreen}{RGB}{0,128,0}
    definecolor{lightgray}{RGB}{238,239,240}


    lstset{
    language=[LaTeX]Tex,
    keywordstyle=color{darkblue},
    texcsstyle=*color{blue},
    basicstyle=normalfontttfamily,
    commentstyle=color{comments}ttfamily,
    stringstyle=rmfamily,
    numbers=none,
    numberstyle=scriptsize,
    numbersep=8pt,
    showstringspaces=false,
    breaklines=true,
    frameround=ftff,
    frame=single,
    captionpos=t,
    belowcaptionskip=0em,
    belowskip=0em,

    literate=
    *{{}{{textcolor{darkred}{{}}}{1}
    {}}{{textcolor{darkred}{}}}}{1}
    {[}{{textcolor{darkred}{[}}}{1}
    {]}{{textcolor{darkred}{]}}}{1},
    }
    lstdefinestyle{mystyle}{
    language=[LaTeX]Tex,
    extendedchars=true,
    breaklines=true,
    breakatwhitespace=true,
    basicstyle=ttfamily,
    numbers=none,
    keywordstyle=color{darkblue},
    keywordstyle=[2]color{blue},
    keywordstyle=[3]color{darkblue},
    keywordstyle=[4]color{drakgreen},
    alsoletter = {!},
    keywords=[2]{definecolor,node,addplot},
    keywords=[3]{usepackage},
    keywords=[4]{begin,end,document,figure,figure*,axis}
    }

    tcbuselibrary{listings,skins,breakable}
    newtcblisting{code}{
    arc=0mm,
    top=0mm,
    bottom=0mm,
    left=3mm,
    right=0mm,
    width=textwidth,
    boxrule=1pt,
    colback=lightgray,
    listing only,
    listing options={style=mystyle},
    breakable
    }

    begin{document}

    begin{code}
    begin{tikzpicture}
    filldraw [gray] (0,0) circle (2pt)
    (1,1) circle (2pt)
    (2,1) circle (2pt)
    (2,0) circle (2pt);
    draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
    end{tikzpicture}
    end{code}
    [/latex]
    When executed, that is, run via pdflatex or via latex followed by dvips, the resulting will contain something that looks like this:

    We are working on
    begin{tikzpicture}
    draw (-1.5,0) -- (1.5,0);
    draw (0,-1.5) -- (0,1.5);
    end{tikzpicture}.

    begin{document}


    enter image description here



    How to eliminate the extra blank lines at the top?









    share
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm using listings to format blocks of code in my xeLaTeX.When I insert this picture into Anki's card, the inserted code has extra blank lines. Following is my MWE:



      documentclass{standalone} 
      usepackage{tcolorbox,listings}
      usepackage{fontspec}
      setmonofont{Consolas}
      usepackage{color}
      usepackage{tikz}
      usepackage{framed}

      definecolor{background}{HTML}{EEEEEE}
      definecolor{comments}{HTML}{868686}
      definecolor{darkred}{RGB}{139,0,0}
      definecolor{darkblue}{RGB}{0,0,139}
      definecolor{chartreuse}{RGB}{127,255,0}
      definecolor{drakgreen}{RGB}{0,128,0}
      definecolor{lightgray}{RGB}{238,239,240}


      lstset{
      language=[LaTeX]Tex,
      keywordstyle=color{darkblue},
      texcsstyle=*color{blue},
      basicstyle=normalfontttfamily,
      commentstyle=color{comments}ttfamily,
      stringstyle=rmfamily,
      numbers=none,
      numberstyle=scriptsize,
      numbersep=8pt,
      showstringspaces=false,
      breaklines=true,
      frameround=ftff,
      frame=single,
      captionpos=t,
      belowcaptionskip=0em,
      belowskip=0em,

      literate=
      *{{}{{textcolor{darkred}{{}}}{1}
      {}}{{textcolor{darkred}{}}}}{1}
      {[}{{textcolor{darkred}{[}}}{1}
      {]}{{textcolor{darkred}{]}}}{1},
      }
      lstdefinestyle{mystyle}{
      language=[LaTeX]Tex,
      extendedchars=true,
      breaklines=true,
      breakatwhitespace=true,
      basicstyle=ttfamily,
      numbers=none,
      keywordstyle=color{darkblue},
      keywordstyle=[2]color{blue},
      keywordstyle=[3]color{darkblue},
      keywordstyle=[4]color{drakgreen},
      alsoletter = {!},
      keywords=[2]{definecolor,node,addplot},
      keywords=[3]{usepackage},
      keywords=[4]{begin,end,document,figure,figure*,axis}
      }

      tcbuselibrary{listings,skins,breakable}
      newtcblisting{code}{
      arc=0mm,
      top=0mm,
      bottom=0mm,
      left=3mm,
      right=0mm,
      width=textwidth,
      boxrule=1pt,
      colback=lightgray,
      listing only,
      listing options={style=mystyle},
      breakable
      }

      begin{document}

      begin{code}
      begin{tikzpicture}
      filldraw [gray] (0,0) circle (2pt)
      (1,1) circle (2pt)
      (2,1) circle (2pt)
      (2,0) circle (2pt);
      draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
      end{tikzpicture}
      end{code}
      [/latex]
      When executed, that is, run via pdflatex or via latex followed by dvips, the resulting will contain something that looks like this:

      We are working on
      begin{tikzpicture}
      draw (-1.5,0) -- (1.5,0);
      draw (0,-1.5) -- (0,1.5);
      end{tikzpicture}.

      begin{document}


      enter image description here



      How to eliminate the extra blank lines at the top?









      share













      I'm using listings to format blocks of code in my xeLaTeX.When I insert this picture into Anki's card, the inserted code has extra blank lines. Following is my MWE:



      documentclass{standalone} 
      usepackage{tcolorbox,listings}
      usepackage{fontspec}
      setmonofont{Consolas}
      usepackage{color}
      usepackage{tikz}
      usepackage{framed}

      definecolor{background}{HTML}{EEEEEE}
      definecolor{comments}{HTML}{868686}
      definecolor{darkred}{RGB}{139,0,0}
      definecolor{darkblue}{RGB}{0,0,139}
      definecolor{chartreuse}{RGB}{127,255,0}
      definecolor{drakgreen}{RGB}{0,128,0}
      definecolor{lightgray}{RGB}{238,239,240}


      lstset{
      language=[LaTeX]Tex,
      keywordstyle=color{darkblue},
      texcsstyle=*color{blue},
      basicstyle=normalfontttfamily,
      commentstyle=color{comments}ttfamily,
      stringstyle=rmfamily,
      numbers=none,
      numberstyle=scriptsize,
      numbersep=8pt,
      showstringspaces=false,
      breaklines=true,
      frameround=ftff,
      frame=single,
      captionpos=t,
      belowcaptionskip=0em,
      belowskip=0em,

      literate=
      *{{}{{textcolor{darkred}{{}}}{1}
      {}}{{textcolor{darkred}{}}}}{1}
      {[}{{textcolor{darkred}{[}}}{1}
      {]}{{textcolor{darkred}{]}}}{1},
      }
      lstdefinestyle{mystyle}{
      language=[LaTeX]Tex,
      extendedchars=true,
      breaklines=true,
      breakatwhitespace=true,
      basicstyle=ttfamily,
      numbers=none,
      keywordstyle=color{darkblue},
      keywordstyle=[2]color{blue},
      keywordstyle=[3]color{darkblue},
      keywordstyle=[4]color{drakgreen},
      alsoletter = {!},
      keywords=[2]{definecolor,node,addplot},
      keywords=[3]{usepackage},
      keywords=[4]{begin,end,document,figure,figure*,axis}
      }

      tcbuselibrary{listings,skins,breakable}
      newtcblisting{code}{
      arc=0mm,
      top=0mm,
      bottom=0mm,
      left=3mm,
      right=0mm,
      width=textwidth,
      boxrule=1pt,
      colback=lightgray,
      listing only,
      listing options={style=mystyle},
      breakable
      }

      begin{document}

      begin{code}
      begin{tikzpicture}
      filldraw [gray] (0,0) circle (2pt)
      (1,1) circle (2pt)
      (2,1) circle (2pt)
      (2,0) circle (2pt);
      draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
      end{tikzpicture}
      end{code}
      [/latex]
      When executed, that is, run via pdflatex or via latex followed by dvips, the resulting will contain something that looks like this:

      We are working on
      begin{tikzpicture}
      draw (-1.5,0) -- (1.5,0);
      draw (0,-1.5) -- (0,1.5);
      end{tikzpicture}.

      begin{document}


      enter image description here



      How to eliminate the extra blank lines at the top?







      listings





      share












      share










      share



      share










      asked 6 mins ago









      mcmxciv

      375




      375



























          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',
          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%2f462321%2fthe-inserted-code-has-extra-blank-lines%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462321%2fthe-inserted-code-has-extra-blank-lines%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

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks