Two lstlistings side by side with refering arrow
Clash Royale CLAN TAG#URR8PPP
SE
I am trying to draw the image below in LaTeX using lstlisting
, tikzpicture
, minipage
, and tabular
The code that I got so far can be seen below
documentclassarticle
usepackage[utf8]inputenc
usepackagetikz
usetikzlibrarytikzmark
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
beginminipage0.8textwidth
begintikzpicture
draw[- >,overlay] (1.5,-2.8) -- node [below] (int, int) (4,-0.8);
endtikzpicture
begintabularcc
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
&
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
endtabular
endminipage
enddocument
The code above results in the following piece of 'art'
Is there anyone that can polish this 'art', so it looks a bit more to the target image?
With kind regards,
Xhendos
EDIT:
Changed my code so it is compileable
tikz-pgf arrows code tikzmark lstlisting
add a comment |
SE
I am trying to draw the image below in LaTeX using lstlisting
, tikzpicture
, minipage
, and tabular
The code that I got so far can be seen below
documentclassarticle
usepackage[utf8]inputenc
usepackagetikz
usetikzlibrarytikzmark
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
beginminipage0.8textwidth
begintikzpicture
draw[- >,overlay] (1.5,-2.8) -- node [below] (int, int) (4,-0.8);
endtikzpicture
begintabularcc
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
&
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
endtabular
endminipage
enddocument
The code above results in the following piece of 'art'
Is there anyone that can polish this 'art', so it looks a bit more to the target image?
With kind regards,
Xhendos
EDIT:
Changed my code so it is compileable
tikz-pgf arrows code tikzmark lstlisting
Please post a compilable example withdocumentclass
, the required packages etc. Not just a fragment.
– Christian Hupfer
Jan 3 at 10:18
Sorry @ChristianHupfer. The code is now compileable
– Xhendos
Jan 3 at 10:24
add a comment |
SE
I am trying to draw the image below in LaTeX using lstlisting
, tikzpicture
, minipage
, and tabular
The code that I got so far can be seen below
documentclassarticle
usepackage[utf8]inputenc
usepackagetikz
usetikzlibrarytikzmark
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
beginminipage0.8textwidth
begintikzpicture
draw[- >,overlay] (1.5,-2.8) -- node [below] (int, int) (4,-0.8);
endtikzpicture
begintabularcc
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
&
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
endtabular
endminipage
enddocument
The code above results in the following piece of 'art'
Is there anyone that can polish this 'art', so it looks a bit more to the target image?
With kind regards,
Xhendos
EDIT:
Changed my code so it is compileable
tikz-pgf arrows code tikzmark lstlisting
SE
I am trying to draw the image below in LaTeX using lstlisting
, tikzpicture
, minipage
, and tabular
The code that I got so far can be seen below
documentclassarticle
usepackage[utf8]inputenc
usepackagetikz
usetikzlibrarytikzmark
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
beginminipage0.8textwidth
begintikzpicture
draw[- >,overlay] (1.5,-2.8) -- node [below] (int, int) (4,-0.8);
endtikzpicture
begintabularcc
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
&
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
endtabular
endminipage
enddocument
The code above results in the following piece of 'art'
Is there anyone that can polish this 'art', so it looks a bit more to the target image?
With kind regards,
Xhendos
EDIT:
Changed my code so it is compileable
tikz-pgf arrows code tikzmark lstlisting
tikz-pgf arrows code tikzmark lstlisting
edited Jan 3 at 10:24
Xhendos
asked Jan 3 at 9:55
XhendosXhendos
404
404
Please post a compilable example withdocumentclass
, the required packages etc. Not just a fragment.
– Christian Hupfer
Jan 3 at 10:18
Sorry @ChristianHupfer. The code is now compileable
– Xhendos
Jan 3 at 10:24
add a comment |
Please post a compilable example withdocumentclass
, the required packages etc. Not just a fragment.
– Christian Hupfer
Jan 3 at 10:18
Sorry @ChristianHupfer. The code is now compileable
– Xhendos
Jan 3 at 10:24
Please post a compilable example with
documentclass
, the required packages etc. Not just a fragment.– Christian Hupfer
Jan 3 at 10:18
Please post a compilable example with
documentclass
, the required packages etc. Not just a fragment.– Christian Hupfer
Jan 3 at 10:18
Sorry @ChristianHupfer. The code is now compileable
– Xhendos
Jan 3 at 10:24
Sorry @ChristianHupfer. The code is now compileable
– Xhendos
Jan 3 at 10:24
add a comment |
2 Answers
2
active
oldest
votes
tikzmark
, which you are loading, has a library for that purpose, listings
, which allows you to refer to lines of the code without actually modifying it. And I am using this nice answer.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark
usetikzmarklibrarylistings
lstsetlanguage=C,
basicstyle=ttfamily,
%frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
newcountertmkcount
tikzset
use tikzmark/.style=
remember picture,
overlay,
execute at end picture=
stepcountertmkcount
,
,
tikzmark suffix=-thetmkcount
begindocument
%beginminipage0.8textwidth
begintabularl
multicolumn1ltextttfile_x.c &
multicolumn1l &
multicolumn1ltextttfile_y.c\
cline1-1 cline3-3
beginlstlisting[language=C,name=codeL]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
begintikzpicture[use tikzmark]
coordinate (aux) at (pic cs:line-codeL-6-end);
endtikzpicture
& &
beginlstlisting[language=C,name=codeR]
void bar(int a, int b)
...
...
...
...
...
endlstlisting\
cline1-1 cline3-3
endtabular
begintikzpicture[use tikzmark]
draw[-latex] ([yshift=2ex,xshift=-3ex]aux) to[bend left=10]
node[midway,above,sloped](int,int) (pic cs:line-codeR-1-start);
endtikzpicture
%endminipage
enddocument
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
add a comment |
as tikz
image:
documentclassarticle
usepackagetikz
usetikzlibrarypositioning, quotes
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
begintikzpicture[
node distance = 22mm,
box/.style = draw, align=left
]
node (a) [box]
hspace*-2em%
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
;
node (b) [box, right=of a]
hspace*-2em%
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
;
draw[->, black!75] ([shift=(2.2,-4.4ex)] a.west) to [pos=0.7,"(int,int)", sloped] ([shift=(2ex,8ex)] b.west);
endtikzpicture
enddocument
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468375%2ftwo-lstlistings-side-by-side-with-refering-arrow%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
tikzmark
, which you are loading, has a library for that purpose, listings
, which allows you to refer to lines of the code without actually modifying it. And I am using this nice answer.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark
usetikzmarklibrarylistings
lstsetlanguage=C,
basicstyle=ttfamily,
%frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
newcountertmkcount
tikzset
use tikzmark/.style=
remember picture,
overlay,
execute at end picture=
stepcountertmkcount
,
,
tikzmark suffix=-thetmkcount
begindocument
%beginminipage0.8textwidth
begintabularl
multicolumn1ltextttfile_x.c &
multicolumn1l &
multicolumn1ltextttfile_y.c\
cline1-1 cline3-3
beginlstlisting[language=C,name=codeL]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
begintikzpicture[use tikzmark]
coordinate (aux) at (pic cs:line-codeL-6-end);
endtikzpicture
& &
beginlstlisting[language=C,name=codeR]
void bar(int a, int b)
...
...
...
...
...
endlstlisting\
cline1-1 cline3-3
endtabular
begintikzpicture[use tikzmark]
draw[-latex] ([yshift=2ex,xshift=-3ex]aux) to[bend left=10]
node[midway,above,sloped](int,int) (pic cs:line-codeR-1-start);
endtikzpicture
%endminipage
enddocument
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
add a comment |
tikzmark
, which you are loading, has a library for that purpose, listings
, which allows you to refer to lines of the code without actually modifying it. And I am using this nice answer.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark
usetikzmarklibrarylistings
lstsetlanguage=C,
basicstyle=ttfamily,
%frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
newcountertmkcount
tikzset
use tikzmark/.style=
remember picture,
overlay,
execute at end picture=
stepcountertmkcount
,
,
tikzmark suffix=-thetmkcount
begindocument
%beginminipage0.8textwidth
begintabularl
multicolumn1ltextttfile_x.c &
multicolumn1l &
multicolumn1ltextttfile_y.c\
cline1-1 cline3-3
beginlstlisting[language=C,name=codeL]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
begintikzpicture[use tikzmark]
coordinate (aux) at (pic cs:line-codeL-6-end);
endtikzpicture
& &
beginlstlisting[language=C,name=codeR]
void bar(int a, int b)
...
...
...
...
...
endlstlisting\
cline1-1 cline3-3
endtabular
begintikzpicture[use tikzmark]
draw[-latex] ([yshift=2ex,xshift=-3ex]aux) to[bend left=10]
node[midway,above,sloped](int,int) (pic cs:line-codeR-1-start);
endtikzpicture
%endminipage
enddocument
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
add a comment |
tikzmark
, which you are loading, has a library for that purpose, listings
, which allows you to refer to lines of the code without actually modifying it. And I am using this nice answer.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark
usetikzmarklibrarylistings
lstsetlanguage=C,
basicstyle=ttfamily,
%frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
newcountertmkcount
tikzset
use tikzmark/.style=
remember picture,
overlay,
execute at end picture=
stepcountertmkcount
,
,
tikzmark suffix=-thetmkcount
begindocument
%beginminipage0.8textwidth
begintabularl
multicolumn1ltextttfile_x.c &
multicolumn1l &
multicolumn1ltextttfile_y.c\
cline1-1 cline3-3
beginlstlisting[language=C,name=codeL]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
begintikzpicture[use tikzmark]
coordinate (aux) at (pic cs:line-codeL-6-end);
endtikzpicture
& &
beginlstlisting[language=C,name=codeR]
void bar(int a, int b)
...
...
...
...
...
endlstlisting\
cline1-1 cline3-3
endtabular
begintikzpicture[use tikzmark]
draw[-latex] ([yshift=2ex,xshift=-3ex]aux) to[bend left=10]
node[midway,above,sloped](int,int) (pic cs:line-codeR-1-start);
endtikzpicture
%endminipage
enddocument
tikzmark
, which you are loading, has a library for that purpose, listings
, which allows you to refer to lines of the code without actually modifying it. And I am using this nice answer.
documentclassarticle
usepackagelistings
usepackagetikz
usetikzlibrarytikzmark
usetikzmarklibrarylistings
lstsetlanguage=C,
basicstyle=ttfamily,
%frame=single,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
newcountertmkcount
tikzset
use tikzmark/.style=
remember picture,
overlay,
execute at end picture=
stepcountertmkcount
,
,
tikzmark suffix=-thetmkcount
begindocument
%beginminipage0.8textwidth
begintabularl
multicolumn1ltextttfile_x.c &
multicolumn1l &
multicolumn1ltextttfile_y.c\
cline1-1 cline3-3
beginlstlisting[language=C,name=codeL]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
begintikzpicture[use tikzmark]
coordinate (aux) at (pic cs:line-codeL-6-end);
endtikzpicture
& &
beginlstlisting[language=C,name=codeR]
void bar(int a, int b)
...
...
...
...
...
endlstlisting\
cline1-1 cline3-3
endtabular
begintikzpicture[use tikzmark]
draw[-latex] ([yshift=2ex,xshift=-3ex]aux) to[bend left=10]
node[midway,above,sloped](int,int) (pic cs:line-codeR-1-start);
endtikzpicture
%endminipage
enddocument
edited Jan 3 at 10:36
answered Jan 3 at 10:29
marmotmarmot
91.9k4107200
91.9k4107200
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
add a comment |
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
I don't know how you do it, but you always surprise me.
– Xhendos
Jan 3 at 10:49
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
@Xhendos Thanks! It's actually all LoopSpace's magic I am trying to use here.
– marmot
Jan 3 at 10:51
add a comment |
as tikz
image:
documentclassarticle
usepackagetikz
usetikzlibrarypositioning, quotes
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
begintikzpicture[
node distance = 22mm,
box/.style = draw, align=left
]
node (a) [box]
hspace*-2em%
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
;
node (b) [box, right=of a]
hspace*-2em%
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
;
draw[->, black!75] ([shift=(2.2,-4.4ex)] a.west) to [pos=0.7,"(int,int)", sloped] ([shift=(2ex,8ex)] b.west);
endtikzpicture
enddocument
add a comment |
as tikz
image:
documentclassarticle
usepackagetikz
usetikzlibrarypositioning, quotes
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
begintikzpicture[
node distance = 22mm,
box/.style = draw, align=left
]
node (a) [box]
hspace*-2em%
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
;
node (b) [box, right=of a]
hspace*-2em%
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
;
draw[->, black!75] ([shift=(2.2,-4.4ex)] a.west) to [pos=0.7,"(int,int)", sloped] ([shift=(2ex,8ex)] b.west);
endtikzpicture
enddocument
add a comment |
as tikz
image:
documentclassarticle
usepackagetikz
usetikzlibrarypositioning, quotes
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
begintikzpicture[
node distance = 22mm,
box/.style = draw, align=left
]
node (a) [box]
hspace*-2em%
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
;
node (b) [box, right=of a]
hspace*-2em%
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
;
draw[->, black!75] ([shift=(2.2,-4.4ex)] a.west) to [pos=0.7,"(int,int)", sloped] ([shift=(2ex,8ex)] b.west);
endtikzpicture
enddocument
as tikz
image:
documentclassarticle
usepackagetikz
usetikzlibrarypositioning, quotes
usepackagelistings
lstsetlanguage=C,
basicstyle=ttfamily,
keywordstyle=colorbluettfamily,
stringstyle=colorredttfamily,
commentstyle=colorgreenttfamily,
morecomment=[l][colormagenta]#
begindocument
begintikzpicture[
node distance = 22mm,
box/.style = draw, align=left
]
node (a) [box]
hspace*-2em%
beginlstlisting[language=C]
void foo()
int q = 5;
int l = 6;
bar(q, l);
endlstlisting
;
node (b) [box, right=of a]
hspace*-2em%
beginlstlisting[language=C]
void bar(int a, int b)
...
...
...
...
endlstlisting
;
draw[->, black!75] ([shift=(2.2,-4.4ex)] a.west) to [pos=0.7,"(int,int)", sloped] ([shift=(2ex,8ex)] b.west);
endtikzpicture
enddocument
edited Jan 3 at 11:05
answered Jan 3 at 10:42
ZarkoZarko
122k865160
122k865160
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468375%2ftwo-lstlistings-side-by-side-with-refering-arrow%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
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
Please post a compilable example with
documentclass
, the required packages etc. Not just a fragment.– Christian Hupfer
Jan 3 at 10:18
Sorry @ChristianHupfer. The code is now compileable
– Xhendos
Jan 3 at 10:24