Escaping within lstlisting adds a space
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I'm basing my code on Overlay red rectangles on top of verbatim text in order to grab draw arrows over the source code.
I've successfully incorporated the solution into my code, however one problem appears: when I escape within lstlisting
, it inserts a space in the source code.
LaTeX source
beginlstlisting
@Template(`This is a /@tikz[remember picture] node (view-left) ;@/ value /@tikz[remember picture] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
Result
Problem
- There are two spaces between
a
andin the template (one was intentional, there's an extra one).
- A space between
in
.
in template. - Double space after
value
in the code.
Why do they appear and how can I get rid of them?
tikz-pgf listings
add a comment |Â
up vote
2
down vote
favorite
I'm basing my code on Overlay red rectangles on top of verbatim text in order to grab draw arrows over the source code.
I've successfully incorporated the solution into my code, however one problem appears: when I escape within lstlisting
, it inserts a space in the source code.
LaTeX source
beginlstlisting
@Template(`This is a /@tikz[remember picture] node (view-left) ;@/ value /@tikz[remember picture] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
Result
Problem
- There are two spaces between
a
andin the template (one was intentional, there's an extra one).
- A space between
in
.
in template. - Double space after
value
in the code.
Why do they appear and how can I get rid of them?
tikz-pgf listings
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm basing my code on Overlay red rectangles on top of verbatim text in order to grab draw arrows over the source code.
I've successfully incorporated the solution into my code, however one problem appears: when I escape within lstlisting
, it inserts a space in the source code.
LaTeX source
beginlstlisting
@Template(`This is a /@tikz[remember picture] node (view-left) ;@/ value /@tikz[remember picture] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
Result
Problem
- There are two spaces between
a
andin the template (one was intentional, there's an extra one).
- A space between
in
.
in template. - Double space after
value
in the code.
Why do they appear and how can I get rid of them?
tikz-pgf listings
I'm basing my code on Overlay red rectangles on top of verbatim text in order to grab draw arrows over the source code.
I've successfully incorporated the solution into my code, however one problem appears: when I escape within lstlisting
, it inserts a space in the source code.
LaTeX source
beginlstlisting
@Template(`This is a /@tikz[remember picture] node (view-left) ;@/ value /@tikz[remember picture] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
Result
Problem
- There are two spaces between
a
andin the template (one was intentional, there's an extra one).
- A space between
in
.
in template. - Double space after
value
in the code.
Why do they appear and how can I get rid of them?
tikz-pgf listings
edited Aug 27 at 21:26
siracusa
3,4471926
3,4471926
asked Aug 26 at 17:33
Lazar Ljubenović
31918
31918
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Instead of enclosing the tikzpicture
in a box of width 0, as @egreg suggests, it is probably easier to work with overlay, which is made for this, or to use the tizkmark
library.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark,calc
lstset
basicstyle=ttfamilysmall,
columns=fullflexible,
escapeinside=/@@/
begindocument
beginlstlisting
@Template(`This is a /@tikz[remember picture,overlay] node (view-left) ;@/ value /@tikz[remember picture,overlay] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture,overlay] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
beginlstlisting
@Template(`This is a /@tikzmarkview-left@/ value /@tikzmarkview-right@/.`)
class Component
value/@tikzmarkcode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(pic cs:view-left)!.5!(pic cs:view-right)$) ;
draw (view.south) to[bend left] ([yshift=-2mm]pic cs:code-right);
endtikzpicture
enddocument
add a comment |Â
up vote
3
down vote
Enclose the TikZ picture in a zero width box:
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarycalc
lstset
basicstyle=ttfamily,
columns=fullflexible,
escapeinside=/@@/,
newcommandfoo[1]%
makebox[0pt]begintikzpicture[remember picture]
node (#1) ;
endtikzpicture%
begindocument
beginlstlisting
@Template(`This is a /@fooview-left@/ value /@fooview-right@/.`)
class Component
value/@foocode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
enddocument
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Instead of enclosing the tikzpicture
in a box of width 0, as @egreg suggests, it is probably easier to work with overlay, which is made for this, or to use the tizkmark
library.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark,calc
lstset
basicstyle=ttfamilysmall,
columns=fullflexible,
escapeinside=/@@/
begindocument
beginlstlisting
@Template(`This is a /@tikz[remember picture,overlay] node (view-left) ;@/ value /@tikz[remember picture,overlay] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture,overlay] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
beginlstlisting
@Template(`This is a /@tikzmarkview-left@/ value /@tikzmarkview-right@/.`)
class Component
value/@tikzmarkcode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(pic cs:view-left)!.5!(pic cs:view-right)$) ;
draw (view.south) to[bend left] ([yshift=-2mm]pic cs:code-right);
endtikzpicture
enddocument
add a comment |Â
up vote
4
down vote
accepted
Instead of enclosing the tikzpicture
in a box of width 0, as @egreg suggests, it is probably easier to work with overlay, which is made for this, or to use the tizkmark
library.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark,calc
lstset
basicstyle=ttfamilysmall,
columns=fullflexible,
escapeinside=/@@/
begindocument
beginlstlisting
@Template(`This is a /@tikz[remember picture,overlay] node (view-left) ;@/ value /@tikz[remember picture,overlay] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture,overlay] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
beginlstlisting
@Template(`This is a /@tikzmarkview-left@/ value /@tikzmarkview-right@/.`)
class Component
value/@tikzmarkcode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(pic cs:view-left)!.5!(pic cs:view-right)$) ;
draw (view.south) to[bend left] ([yshift=-2mm]pic cs:code-right);
endtikzpicture
enddocument
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Instead of enclosing the tikzpicture
in a box of width 0, as @egreg suggests, it is probably easier to work with overlay, which is made for this, or to use the tizkmark
library.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark,calc
lstset
basicstyle=ttfamilysmall,
columns=fullflexible,
escapeinside=/@@/
begindocument
beginlstlisting
@Template(`This is a /@tikz[remember picture,overlay] node (view-left) ;@/ value /@tikz[remember picture,overlay] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture,overlay] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
beginlstlisting
@Template(`This is a /@tikzmarkview-left@/ value /@tikzmarkview-right@/.`)
class Component
value/@tikzmarkcode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(pic cs:view-left)!.5!(pic cs:view-right)$) ;
draw (view.south) to[bend left] ([yshift=-2mm]pic cs:code-right);
endtikzpicture
enddocument
Instead of enclosing the tikzpicture
in a box of width 0, as @egreg suggests, it is probably easier to work with overlay, which is made for this, or to use the tizkmark
library.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark,calc
lstset
basicstyle=ttfamilysmall,
columns=fullflexible,
escapeinside=/@@/
begindocument
beginlstlisting
@Template(`This is a /@tikz[remember picture,overlay] node (view-left) ;@/ value /@tikz[remember picture,overlay] node (view-right) ;@/.`)
class Component
value/@tikz[remember picture,overlay] node (code-right) ;@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
beginlstlisting
@Template(`This is a /@tikzmarkview-left@/ value /@tikzmarkview-right@/.`)
class Component
value/@tikzmarkcode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(pic cs:view-left)!.5!(pic cs:view-right)$) ;
draw (view.south) to[bend left] ([yshift=-2mm]pic cs:code-right);
endtikzpicture
enddocument
answered Aug 26 at 18:09


marmot
55.8k461121
55.8k461121
add a comment |Â
add a comment |Â
up vote
3
down vote
Enclose the TikZ picture in a zero width box:
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarycalc
lstset
basicstyle=ttfamily,
columns=fullflexible,
escapeinside=/@@/,
newcommandfoo[1]%
makebox[0pt]begintikzpicture[remember picture]
node (#1) ;
endtikzpicture%
begindocument
beginlstlisting
@Template(`This is a /@fooview-left@/ value /@fooview-right@/.`)
class Component
value/@foocode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
enddocument
add a comment |Â
up vote
3
down vote
Enclose the TikZ picture in a zero width box:
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarycalc
lstset
basicstyle=ttfamily,
columns=fullflexible,
escapeinside=/@@/,
newcommandfoo[1]%
makebox[0pt]begintikzpicture[remember picture]
node (#1) ;
endtikzpicture%
begindocument
beginlstlisting
@Template(`This is a /@fooview-left@/ value /@fooview-right@/.`)
class Component
value/@foocode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
enddocument
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Enclose the TikZ picture in a zero width box:
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarycalc
lstset
basicstyle=ttfamily,
columns=fullflexible,
escapeinside=/@@/,
newcommandfoo[1]%
makebox[0pt]begintikzpicture[remember picture]
node (#1) ;
endtikzpicture%
begindocument
beginlstlisting
@Template(`This is a /@fooview-left@/ value /@fooview-right@/.`)
class Component
value/@foocode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
enddocument
Enclose the TikZ picture in a zero width box:
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarycalc
lstset
basicstyle=ttfamily,
columns=fullflexible,
escapeinside=/@@/,
newcommandfoo[1]%
makebox[0pt]begintikzpicture[remember picture]
node (#1) ;
endtikzpicture%
begindocument
beginlstlisting
@Template(`This is a /@fooview-left@/ value /@fooview-right@/.`)
class Component
value/@foocode-right@/ = 21
endlstlisting
begintikzpicture[remember picture, overlay]
node (view) at ($(view-left)!.5!(view-right)$) ;
draw (view.south) edge [bend left] (code-right.south east);
endtikzpicture
enddocument
answered Aug 26 at 18:05


egreg
680k8318083056
680k8318083056
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447828%2fescaping-within-lstlisting-adds-a-space%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password