Drawing a memory layout diagram with TikzBetter way of designing memory layout in tikzDisplaying memory variable valuesDrawing a packet layout with TikZDrawing flow diagram in LaTeX using TikZDrawing a block diagram with TiKzDrawing diagram in TikZDrawing a block diagram in Tikzexceeding memory with tikz (even after externalise)Drawing Color Diagram with TikzVariable/counter for each object/instance using a template with tikzset and /.style?Drawing a Decision Diagram with Tikz and layout manager

Security Patch SUPEE-11155 - Possible issues?

How hard is it to sell a home which is currently mortgaged?

Put my student loan in parents’ second mortgage - help?

Is there a legal way for US presidents to extend their terms beyond four years?

What is the purpose of putting a capacitor on the primary side of a step-down transformer?

In native German words, is Q always followed by U, as in English?

How to organize members in a struct to waste least space on alignment?

Drawing a memory layout diagram with Tikz

Could a Weapon of Mass Destruction, targeting only humans, be developed?

Was it really unprofessional of me to leave without asking for a raise first?

Why were the first airplanes "backwards"?

Graph problems as integer programs

For decoupling an IC's power supply pins, is there any reason to use multiple capacitances when all the MLCCs have the same package size?

What are good ways to spray paint a QR code on a footpath?

What exactly did Ant-Man see that made him say that their plan worked?

Why do changes to /etc/hosts take effect immediately?

Apex Class Deployment: duplicate value found: <unknown> duplicates value on record with id: <unknown>

What could a reptilian race tell by candling their eggs?

Step into the Octagram

Is there a canon reason why Klingon and Romulan vessels are so similar in shape?

Why won't the ground take my seed?

What game is this character in the Pixels movie from?

How did researchers find articles before the Internet and the computer era?

Which is better for keeping data primary partition or logical partition?



Drawing a memory layout diagram with Tikz


Better way of designing memory layout in tikzDisplaying memory variable valuesDrawing a packet layout with TikZDrawing flow diagram in LaTeX using TikZDrawing a block diagram with TiKzDrawing diagram in TikZDrawing a block diagram in Tikzexceeding memory with tikz (even after externalise)Drawing Color Diagram with TikzVariable/counter for each object/instance using a template with tikzset and /.style?Drawing a Decision Diagram with Tikz and layout manager






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'd like to draw a memory layout diagram in Tikz that looks a bit like the following:
enter image description here
Note that the original was an SVG file, and conversion to PNG causes the weird [Not supported by viewer] errors, not sure what that's about.



Anyway, how can I recreate that diagram in Tikz, but without the numbered stages, and with the sections starting at the very left?



I tried to modify this answer to near it to the posted image, but I don't know enough Tikz to get it quite there.










share|improve this question
























  • What have to tried so far?

    – Skillmon
    8 hours ago











  • @Skillmon I tried hacking around the answer to this question[1] but my Tikz knowledge wasn't enough to get it anywhere close. [1]: tex.stackexchange.com/questions/430577/…

    – Bernardo Meurer
    8 hours ago











  • You could include the code you tried so far in your question.

    – Skillmon
    8 hours ago











  • I'll add a reference to that question while I try to salvage my attempt from Vim's history

    – Bernardo Meurer
    8 hours ago











  • ctan.org/pkg/bytefield

    – Henri Menke
    8 hours ago

















1















I'd like to draw a memory layout diagram in Tikz that looks a bit like the following:
enter image description here
Note that the original was an SVG file, and conversion to PNG causes the weird [Not supported by viewer] errors, not sure what that's about.



Anyway, how can I recreate that diagram in Tikz, but without the numbered stages, and with the sections starting at the very left?



I tried to modify this answer to near it to the posted image, but I don't know enough Tikz to get it quite there.










share|improve this question
























  • What have to tried so far?

    – Skillmon
    8 hours ago











  • @Skillmon I tried hacking around the answer to this question[1] but my Tikz knowledge wasn't enough to get it anywhere close. [1]: tex.stackexchange.com/questions/430577/…

    – Bernardo Meurer
    8 hours ago











  • You could include the code you tried so far in your question.

    – Skillmon
    8 hours ago











  • I'll add a reference to that question while I try to salvage my attempt from Vim's history

    – Bernardo Meurer
    8 hours ago











  • ctan.org/pkg/bytefield

    – Henri Menke
    8 hours ago













1












1








1








I'd like to draw a memory layout diagram in Tikz that looks a bit like the following:
enter image description here
Note that the original was an SVG file, and conversion to PNG causes the weird [Not supported by viewer] errors, not sure what that's about.



Anyway, how can I recreate that diagram in Tikz, but without the numbered stages, and with the sections starting at the very left?



I tried to modify this answer to near it to the posted image, but I don't know enough Tikz to get it quite there.










share|improve this question
















I'd like to draw a memory layout diagram in Tikz that looks a bit like the following:
enter image description here
Note that the original was an SVG file, and conversion to PNG causes the weird [Not supported by viewer] errors, not sure what that's about.



Anyway, how can I recreate that diagram in Tikz, but without the numbered stages, and with the sections starting at the very left?



I tried to modify this answer to near it to the posted image, but I don't know enough Tikz to get it quite there.







tikz-pgf diagrams memory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago







Bernardo Meurer

















asked 8 hours ago









Bernardo MeurerBernardo Meurer

2711 silver badge9 bronze badges




2711 silver badge9 bronze badges












  • What have to tried so far?

    – Skillmon
    8 hours ago











  • @Skillmon I tried hacking around the answer to this question[1] but my Tikz knowledge wasn't enough to get it anywhere close. [1]: tex.stackexchange.com/questions/430577/…

    – Bernardo Meurer
    8 hours ago











  • You could include the code you tried so far in your question.

    – Skillmon
    8 hours ago











  • I'll add a reference to that question while I try to salvage my attempt from Vim's history

    – Bernardo Meurer
    8 hours ago











  • ctan.org/pkg/bytefield

    – Henri Menke
    8 hours ago

















  • What have to tried so far?

    – Skillmon
    8 hours ago











  • @Skillmon I tried hacking around the answer to this question[1] but my Tikz knowledge wasn't enough to get it anywhere close. [1]: tex.stackexchange.com/questions/430577/…

    – Bernardo Meurer
    8 hours ago











  • You could include the code you tried so far in your question.

    – Skillmon
    8 hours ago











  • I'll add a reference to that question while I try to salvage my attempt from Vim's history

    – Bernardo Meurer
    8 hours ago











  • ctan.org/pkg/bytefield

    – Henri Menke
    8 hours ago
















What have to tried so far?

– Skillmon
8 hours ago





What have to tried so far?

– Skillmon
8 hours ago













@Skillmon I tried hacking around the answer to this question[1] but my Tikz knowledge wasn't enough to get it anywhere close. [1]: tex.stackexchange.com/questions/430577/…

– Bernardo Meurer
8 hours ago





@Skillmon I tried hacking around the answer to this question[1] but my Tikz knowledge wasn't enough to get it anywhere close. [1]: tex.stackexchange.com/questions/430577/…

– Bernardo Meurer
8 hours ago













You could include the code you tried so far in your question.

– Skillmon
8 hours ago





You could include the code you tried so far in your question.

– Skillmon
8 hours ago













I'll add a reference to that question while I try to salvage my attempt from Vim's history

– Bernardo Meurer
8 hours ago





I'll add a reference to that question while I try to salvage my attempt from Vim's history

– Bernardo Meurer
8 hours ago













ctan.org/pkg/bytefield

– Henri Menke
8 hours ago





ctan.org/pkg/bytefield

– Henri Menke
8 hours ago










2 Answers
2






active

oldest

votes


















3














Something like this:



enter image description here
This is done using tikz but to hide the technicalities I have defined a macro MemoryLayout that accepts a coma separated list of x-coordinates/colours/labels so that the image above was produced by:



MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax



Use a label of relax when you do not want a label.



All that this macro does is loop over the input data to draw the picture using standard tikz commands. Here is the full code:



documentclass[tikz, border=5mm]standalone
usetikzlibrarydecorations.pathreplacing

newcommandMemoryLayout[1]
begintikzpicture[scale=0.3]
draw[thick](0,0)--++(0,3)node[above]$0$;
foreach pt/col/lab [remember=pt as tp (initially 0)] in #1
foreach a in tp,...,pt-1
draw[fill=col](-a,0) rectangle ++(-1,2);

draw[thick](-pt,0)--++(0,3)node[above]$pt$;
iflabrelaxrelaxelse
draw[thick,decorate, decoration=brace,amplitude=4mm]
(-tp,-0.2)--node[below=4mm]lab (-pt,-0.2);
fi

endtikzpicture


begindocument

MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax


enddocument


To remove the numbers just comment out the two draw[thick]...; commands.






share|improve this answer

























  • I love it! Thank you!

    – Bernardo Meurer
    6 hours ago


















3














Just for fun an implementation using only xcolor (and amstext for text in the labels below the brace). The memory command takes the following arguments:



memory[<width>]<num>[<height>]<color>[<label>]


<width>
: is the width of a single cell



<height>
: is the height of the cells



<color>
: is the colour used by the cells, it can contain an optional argument and a mandatory one, or just the mandatory one forwarded to textcolor, so both [gray].85 and white!85!black are valid.



<label>
: the text which is printed below the brace, if it is left out no brace will be drawn.



The borders' thickness is the current value of fboxrule, the rules don't add to the size of the cells. To draw more than a single block of memory, just put multiple memory instances after each other, make sure to not put a space in between. The size of the <label> might create white space, you'd have to take care for that.



documentclass[]article

usepackageamstext
usepackagexcolor

makeatletter
begingroup
lccode`A=`-
lccode`N=`N
lccode`V=`V
lowercaseendgroupdefmemory@novalANoValue-
longdefmemory@fiBgbfi#1#2fi
longdefmemory@fiTBbfi#1#2#3fi#2
newcommandmemory@ifnovalF[1]%>>=
%
ifxmemory@noval#1%
memory@fiBgb
fi
@firstofone
%=<<
newcommandmemory@ifnovalTF[1]%>>=
%
ifxmemory@noval#1%
memory@fiTBb
fi
@secondoftwo
%=<<
newcommandmemory@Oarg[2]%>>=
%
@ifnextchar[memory@Oarg@#2#2#1%
%=<<
longdefmemory@Oarg@#1[#2]%>>=
%
#1#2%
%=<<
newcommand*memory@oarg%>>=
%
memory@Oargmemory@noval
%=<<
newcommand*memory@ifcoloropt%>>=
%
@ifnextchar[memory@ifcoloropt@truememory@ifcoloropt@false
%=<<
longdefmemory@ifcoloropt@true#1memory@noval#2#3%>>=
%
#2%
%=<<
longdefmemory@ifcoloropt@false#1memory@noval#2#3%>>=
%
#3%
%=<<
newlengthmemory@width
newlengthmemory@height
setlengthmemory@width7pt
setlengthmemory@height10pt
newcountmemory@num
newcommand*memory@blocks[2]%>>=
%
memory@num#1relax
fboxsep-fboxrule
memory@ifcoloropt#2memory@noval
defmemory@colortextcolor#2
defmemory@colortextcolor#2%
loop
ifnummemory@num>0
fboxmemory@colorrulememory@widthmemory@height%
kern-fboxrule
advancememory@numm@ne
repeat
%=<<
% memory:
% [#1]: width
% #2 : count
% [#3]: height
% #4 : colour
% [#5]: label
newcommand*memory%>>=
%
begingroup
memory@oargmemory@a
%=<<
newcommand*memory@a[2]%>>=
%
% #1 width
% #2 count
memory@ifnovalF#1memory@width#1relax%
memory@Oargmemory@heightmemory@b#2%
%=<<
newcommand*memory@b[3]%>>=
%
% #1 count
% #2 height
% #3 colour
memory@ifnovalF#2memory@height#2relax%
memory@oargmemory@c#1#3%
%=<<
newcommand*memory@c[3]%>>=
%
% #1 count
% #2 colour
% #3 label
memory@ifnovalTF#3
ensuremathmemory@blocks#1#2
ensuremathunderbracememory@blocks#1#2_text#3%
endgroup
%=<<
makeatother

begindocument
memory8orange%
memory8green[makebox[0pt][Not supported by viewer]]%
memory8yellow%
enddocument

% vim: fdm=marker fmr=>>=,=<<


enter image description here






share|improve this answer

























  • This is absolutely amazing, right down to the [Not supported by viewer]!

    – Bernardo Meurer
    6 hours ago













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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f497431%2fdrawing-a-memory-layout-diagram-with-tikz%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









3














Something like this:



enter image description here
This is done using tikz but to hide the technicalities I have defined a macro MemoryLayout that accepts a coma separated list of x-coordinates/colours/labels so that the image above was produced by:



MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax



Use a label of relax when you do not want a label.



All that this macro does is loop over the input data to draw the picture using standard tikz commands. Here is the full code:



documentclass[tikz, border=5mm]standalone
usetikzlibrarydecorations.pathreplacing

newcommandMemoryLayout[1]
begintikzpicture[scale=0.3]
draw[thick](0,0)--++(0,3)node[above]$0$;
foreach pt/col/lab [remember=pt as tp (initially 0)] in #1
foreach a in tp,...,pt-1
draw[fill=col](-a,0) rectangle ++(-1,2);

draw[thick](-pt,0)--++(0,3)node[above]$pt$;
iflabrelaxrelaxelse
draw[thick,decorate, decoration=brace,amplitude=4mm]
(-tp,-0.2)--node[below=4mm]lab (-pt,-0.2);
fi

endtikzpicture


begindocument

MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax


enddocument


To remove the numbers just comment out the two draw[thick]...; commands.






share|improve this answer

























  • I love it! Thank you!

    – Bernardo Meurer
    6 hours ago















3














Something like this:



enter image description here
This is done using tikz but to hide the technicalities I have defined a macro MemoryLayout that accepts a coma separated list of x-coordinates/colours/labels so that the image above was produced by:



MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax



Use a label of relax when you do not want a label.



All that this macro does is loop over the input data to draw the picture using standard tikz commands. Here is the full code:



documentclass[tikz, border=5mm]standalone
usetikzlibrarydecorations.pathreplacing

newcommandMemoryLayout[1]
begintikzpicture[scale=0.3]
draw[thick](0,0)--++(0,3)node[above]$0$;
foreach pt/col/lab [remember=pt as tp (initially 0)] in #1
foreach a in tp,...,pt-1
draw[fill=col](-a,0) rectangle ++(-1,2);

draw[thick](-pt,0)--++(0,3)node[above]$pt$;
iflabrelaxrelaxelse
draw[thick,decorate, decoration=brace,amplitude=4mm]
(-tp,-0.2)--node[below=4mm]lab (-pt,-0.2);
fi

endtikzpicture


begindocument

MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax


enddocument


To remove the numbers just comment out the two draw[thick]...; commands.






share|improve this answer

























  • I love it! Thank you!

    – Bernardo Meurer
    6 hours ago













3












3








3







Something like this:



enter image description here
This is done using tikz but to hide the technicalities I have defined a macro MemoryLayout that accepts a coma separated list of x-coordinates/colours/labels so that the image above was produced by:



MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax



Use a label of relax when you do not want a label.



All that this macro does is loop over the input data to draw the picture using standard tikz commands. Here is the full code:



documentclass[tikz, border=5mm]standalone
usetikzlibrarydecorations.pathreplacing

newcommandMemoryLayout[1]
begintikzpicture[scale=0.3]
draw[thick](0,0)--++(0,3)node[above]$0$;
foreach pt/col/lab [remember=pt as tp (initially 0)] in #1
foreach a in tp,...,pt-1
draw[fill=col](-a,0) rectangle ++(-1,2);

draw[thick](-pt,0)--++(0,3)node[above]$pt$;
iflabrelaxrelaxelse
draw[thick,decorate, decoration=brace,amplitude=4mm]
(-tp,-0.2)--node[below=4mm]lab (-pt,-0.2);
fi

endtikzpicture


begindocument

MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax


enddocument


To remove the numbers just comment out the two draw[thick]...; commands.






share|improve this answer















Something like this:



enter image description here
This is done using tikz but to hide the technicalities I have defined a macro MemoryLayout that accepts a coma separated list of x-coordinates/colours/labels so that the image above was produced by:



MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax



Use a label of relax when you do not want a label.



All that this macro does is loop over the input data to draw the picture using standard tikz commands. Here is the full code:



documentclass[tikz, border=5mm]standalone
usetikzlibrarydecorations.pathreplacing

newcommandMemoryLayout[1]
begintikzpicture[scale=0.3]
draw[thick](0,0)--++(0,3)node[above]$0$;
foreach pt/col/lab [remember=pt as tp (initially 0)] in #1
foreach a in tp,...,pt-1
draw[fill=col](-a,0) rectangle ++(-1,2);

draw[thick](-pt,0)--++(0,3)node[above]$pt$;
iflabrelaxrelaxelse
draw[thick,decorate, decoration=brace,amplitude=4mm]
(-tp,-0.2)--node[below=4mm]lab (-pt,-0.2);
fi

endtikzpicture


begindocument

MemoryLayout
12/blue!10/A,
21/orange!20/B,
30/red!30/C,
39/yellow!30/D,
48/green!30/E,
62/white/relax


enddocument


To remove the numbers just comment out the two draw[thick]...; commands.







share|improve this answer














share|improve this answer



share|improve this answer








edited 6 hours ago

























answered 6 hours ago









AndrewAndrew

34k3 gold badges50 silver badges88 bronze badges




34k3 gold badges50 silver badges88 bronze badges












  • I love it! Thank you!

    – Bernardo Meurer
    6 hours ago

















  • I love it! Thank you!

    – Bernardo Meurer
    6 hours ago
















I love it! Thank you!

– Bernardo Meurer
6 hours ago





I love it! Thank you!

– Bernardo Meurer
6 hours ago













3














Just for fun an implementation using only xcolor (and amstext for text in the labels below the brace). The memory command takes the following arguments:



memory[<width>]<num>[<height>]<color>[<label>]


<width>
: is the width of a single cell



<height>
: is the height of the cells



<color>
: is the colour used by the cells, it can contain an optional argument and a mandatory one, or just the mandatory one forwarded to textcolor, so both [gray].85 and white!85!black are valid.



<label>
: the text which is printed below the brace, if it is left out no brace will be drawn.



The borders' thickness is the current value of fboxrule, the rules don't add to the size of the cells. To draw more than a single block of memory, just put multiple memory instances after each other, make sure to not put a space in between. The size of the <label> might create white space, you'd have to take care for that.



documentclass[]article

usepackageamstext
usepackagexcolor

makeatletter
begingroup
lccode`A=`-
lccode`N=`N
lccode`V=`V
lowercaseendgroupdefmemory@novalANoValue-
longdefmemory@fiBgbfi#1#2fi
longdefmemory@fiTBbfi#1#2#3fi#2
newcommandmemory@ifnovalF[1]%>>=
%
ifxmemory@noval#1%
memory@fiBgb
fi
@firstofone
%=<<
newcommandmemory@ifnovalTF[1]%>>=
%
ifxmemory@noval#1%
memory@fiTBb
fi
@secondoftwo
%=<<
newcommandmemory@Oarg[2]%>>=
%
@ifnextchar[memory@Oarg@#2#2#1%
%=<<
longdefmemory@Oarg@#1[#2]%>>=
%
#1#2%
%=<<
newcommand*memory@oarg%>>=
%
memory@Oargmemory@noval
%=<<
newcommand*memory@ifcoloropt%>>=
%
@ifnextchar[memory@ifcoloropt@truememory@ifcoloropt@false
%=<<
longdefmemory@ifcoloropt@true#1memory@noval#2#3%>>=
%
#2%
%=<<
longdefmemory@ifcoloropt@false#1memory@noval#2#3%>>=
%
#3%
%=<<
newlengthmemory@width
newlengthmemory@height
setlengthmemory@width7pt
setlengthmemory@height10pt
newcountmemory@num
newcommand*memory@blocks[2]%>>=
%
memory@num#1relax
fboxsep-fboxrule
memory@ifcoloropt#2memory@noval
defmemory@colortextcolor#2
defmemory@colortextcolor#2%
loop
ifnummemory@num>0
fboxmemory@colorrulememory@widthmemory@height%
kern-fboxrule
advancememory@numm@ne
repeat
%=<<
% memory:
% [#1]: width
% #2 : count
% [#3]: height
% #4 : colour
% [#5]: label
newcommand*memory%>>=
%
begingroup
memory@oargmemory@a
%=<<
newcommand*memory@a[2]%>>=
%
% #1 width
% #2 count
memory@ifnovalF#1memory@width#1relax%
memory@Oargmemory@heightmemory@b#2%
%=<<
newcommand*memory@b[3]%>>=
%
% #1 count
% #2 height
% #3 colour
memory@ifnovalF#2memory@height#2relax%
memory@oargmemory@c#1#3%
%=<<
newcommand*memory@c[3]%>>=
%
% #1 count
% #2 colour
% #3 label
memory@ifnovalTF#3
ensuremathmemory@blocks#1#2
ensuremathunderbracememory@blocks#1#2_text#3%
endgroup
%=<<
makeatother

begindocument
memory8orange%
memory8green[makebox[0pt][Not supported by viewer]]%
memory8yellow%
enddocument

% vim: fdm=marker fmr=>>=,=<<


enter image description here






share|improve this answer

























  • This is absolutely amazing, right down to the [Not supported by viewer]!

    – Bernardo Meurer
    6 hours ago















3














Just for fun an implementation using only xcolor (and amstext for text in the labels below the brace). The memory command takes the following arguments:



memory[<width>]<num>[<height>]<color>[<label>]


<width>
: is the width of a single cell



<height>
: is the height of the cells



<color>
: is the colour used by the cells, it can contain an optional argument and a mandatory one, or just the mandatory one forwarded to textcolor, so both [gray].85 and white!85!black are valid.



<label>
: the text which is printed below the brace, if it is left out no brace will be drawn.



The borders' thickness is the current value of fboxrule, the rules don't add to the size of the cells. To draw more than a single block of memory, just put multiple memory instances after each other, make sure to not put a space in between. The size of the <label> might create white space, you'd have to take care for that.



documentclass[]article

usepackageamstext
usepackagexcolor

makeatletter
begingroup
lccode`A=`-
lccode`N=`N
lccode`V=`V
lowercaseendgroupdefmemory@novalANoValue-
longdefmemory@fiBgbfi#1#2fi
longdefmemory@fiTBbfi#1#2#3fi#2
newcommandmemory@ifnovalF[1]%>>=
%
ifxmemory@noval#1%
memory@fiBgb
fi
@firstofone
%=<<
newcommandmemory@ifnovalTF[1]%>>=
%
ifxmemory@noval#1%
memory@fiTBb
fi
@secondoftwo
%=<<
newcommandmemory@Oarg[2]%>>=
%
@ifnextchar[memory@Oarg@#2#2#1%
%=<<
longdefmemory@Oarg@#1[#2]%>>=
%
#1#2%
%=<<
newcommand*memory@oarg%>>=
%
memory@Oargmemory@noval
%=<<
newcommand*memory@ifcoloropt%>>=
%
@ifnextchar[memory@ifcoloropt@truememory@ifcoloropt@false
%=<<
longdefmemory@ifcoloropt@true#1memory@noval#2#3%>>=
%
#2%
%=<<
longdefmemory@ifcoloropt@false#1memory@noval#2#3%>>=
%
#3%
%=<<
newlengthmemory@width
newlengthmemory@height
setlengthmemory@width7pt
setlengthmemory@height10pt
newcountmemory@num
newcommand*memory@blocks[2]%>>=
%
memory@num#1relax
fboxsep-fboxrule
memory@ifcoloropt#2memory@noval
defmemory@colortextcolor#2
defmemory@colortextcolor#2%
loop
ifnummemory@num>0
fboxmemory@colorrulememory@widthmemory@height%
kern-fboxrule
advancememory@numm@ne
repeat
%=<<
% memory:
% [#1]: width
% #2 : count
% [#3]: height
% #4 : colour
% [#5]: label
newcommand*memory%>>=
%
begingroup
memory@oargmemory@a
%=<<
newcommand*memory@a[2]%>>=
%
% #1 width
% #2 count
memory@ifnovalF#1memory@width#1relax%
memory@Oargmemory@heightmemory@b#2%
%=<<
newcommand*memory@b[3]%>>=
%
% #1 count
% #2 height
% #3 colour
memory@ifnovalF#2memory@height#2relax%
memory@oargmemory@c#1#3%
%=<<
newcommand*memory@c[3]%>>=
%
% #1 count
% #2 colour
% #3 label
memory@ifnovalTF#3
ensuremathmemory@blocks#1#2
ensuremathunderbracememory@blocks#1#2_text#3%
endgroup
%=<<
makeatother

begindocument
memory8orange%
memory8green[makebox[0pt][Not supported by viewer]]%
memory8yellow%
enddocument

% vim: fdm=marker fmr=>>=,=<<


enter image description here






share|improve this answer

























  • This is absolutely amazing, right down to the [Not supported by viewer]!

    – Bernardo Meurer
    6 hours ago













3












3








3







Just for fun an implementation using only xcolor (and amstext for text in the labels below the brace). The memory command takes the following arguments:



memory[<width>]<num>[<height>]<color>[<label>]


<width>
: is the width of a single cell



<height>
: is the height of the cells



<color>
: is the colour used by the cells, it can contain an optional argument and a mandatory one, or just the mandatory one forwarded to textcolor, so both [gray].85 and white!85!black are valid.



<label>
: the text which is printed below the brace, if it is left out no brace will be drawn.



The borders' thickness is the current value of fboxrule, the rules don't add to the size of the cells. To draw more than a single block of memory, just put multiple memory instances after each other, make sure to not put a space in between. The size of the <label> might create white space, you'd have to take care for that.



documentclass[]article

usepackageamstext
usepackagexcolor

makeatletter
begingroup
lccode`A=`-
lccode`N=`N
lccode`V=`V
lowercaseendgroupdefmemory@novalANoValue-
longdefmemory@fiBgbfi#1#2fi
longdefmemory@fiTBbfi#1#2#3fi#2
newcommandmemory@ifnovalF[1]%>>=
%
ifxmemory@noval#1%
memory@fiBgb
fi
@firstofone
%=<<
newcommandmemory@ifnovalTF[1]%>>=
%
ifxmemory@noval#1%
memory@fiTBb
fi
@secondoftwo
%=<<
newcommandmemory@Oarg[2]%>>=
%
@ifnextchar[memory@Oarg@#2#2#1%
%=<<
longdefmemory@Oarg@#1[#2]%>>=
%
#1#2%
%=<<
newcommand*memory@oarg%>>=
%
memory@Oargmemory@noval
%=<<
newcommand*memory@ifcoloropt%>>=
%
@ifnextchar[memory@ifcoloropt@truememory@ifcoloropt@false
%=<<
longdefmemory@ifcoloropt@true#1memory@noval#2#3%>>=
%
#2%
%=<<
longdefmemory@ifcoloropt@false#1memory@noval#2#3%>>=
%
#3%
%=<<
newlengthmemory@width
newlengthmemory@height
setlengthmemory@width7pt
setlengthmemory@height10pt
newcountmemory@num
newcommand*memory@blocks[2]%>>=
%
memory@num#1relax
fboxsep-fboxrule
memory@ifcoloropt#2memory@noval
defmemory@colortextcolor#2
defmemory@colortextcolor#2%
loop
ifnummemory@num>0
fboxmemory@colorrulememory@widthmemory@height%
kern-fboxrule
advancememory@numm@ne
repeat
%=<<
% memory:
% [#1]: width
% #2 : count
% [#3]: height
% #4 : colour
% [#5]: label
newcommand*memory%>>=
%
begingroup
memory@oargmemory@a
%=<<
newcommand*memory@a[2]%>>=
%
% #1 width
% #2 count
memory@ifnovalF#1memory@width#1relax%
memory@Oargmemory@heightmemory@b#2%
%=<<
newcommand*memory@b[3]%>>=
%
% #1 count
% #2 height
% #3 colour
memory@ifnovalF#2memory@height#2relax%
memory@oargmemory@c#1#3%
%=<<
newcommand*memory@c[3]%>>=
%
% #1 count
% #2 colour
% #3 label
memory@ifnovalTF#3
ensuremathmemory@blocks#1#2
ensuremathunderbracememory@blocks#1#2_text#3%
endgroup
%=<<
makeatother

begindocument
memory8orange%
memory8green[makebox[0pt][Not supported by viewer]]%
memory8yellow%
enddocument

% vim: fdm=marker fmr=>>=,=<<


enter image description here






share|improve this answer















Just for fun an implementation using only xcolor (and amstext for text in the labels below the brace). The memory command takes the following arguments:



memory[<width>]<num>[<height>]<color>[<label>]


<width>
: is the width of a single cell



<height>
: is the height of the cells



<color>
: is the colour used by the cells, it can contain an optional argument and a mandatory one, or just the mandatory one forwarded to textcolor, so both [gray].85 and white!85!black are valid.



<label>
: the text which is printed below the brace, if it is left out no brace will be drawn.



The borders' thickness is the current value of fboxrule, the rules don't add to the size of the cells. To draw more than a single block of memory, just put multiple memory instances after each other, make sure to not put a space in between. The size of the <label> might create white space, you'd have to take care for that.



documentclass[]article

usepackageamstext
usepackagexcolor

makeatletter
begingroup
lccode`A=`-
lccode`N=`N
lccode`V=`V
lowercaseendgroupdefmemory@novalANoValue-
longdefmemory@fiBgbfi#1#2fi
longdefmemory@fiTBbfi#1#2#3fi#2
newcommandmemory@ifnovalF[1]%>>=
%
ifxmemory@noval#1%
memory@fiBgb
fi
@firstofone
%=<<
newcommandmemory@ifnovalTF[1]%>>=
%
ifxmemory@noval#1%
memory@fiTBb
fi
@secondoftwo
%=<<
newcommandmemory@Oarg[2]%>>=
%
@ifnextchar[memory@Oarg@#2#2#1%
%=<<
longdefmemory@Oarg@#1[#2]%>>=
%
#1#2%
%=<<
newcommand*memory@oarg%>>=
%
memory@Oargmemory@noval
%=<<
newcommand*memory@ifcoloropt%>>=
%
@ifnextchar[memory@ifcoloropt@truememory@ifcoloropt@false
%=<<
longdefmemory@ifcoloropt@true#1memory@noval#2#3%>>=
%
#2%
%=<<
longdefmemory@ifcoloropt@false#1memory@noval#2#3%>>=
%
#3%
%=<<
newlengthmemory@width
newlengthmemory@height
setlengthmemory@width7pt
setlengthmemory@height10pt
newcountmemory@num
newcommand*memory@blocks[2]%>>=
%
memory@num#1relax
fboxsep-fboxrule
memory@ifcoloropt#2memory@noval
defmemory@colortextcolor#2
defmemory@colortextcolor#2%
loop
ifnummemory@num>0
fboxmemory@colorrulememory@widthmemory@height%
kern-fboxrule
advancememory@numm@ne
repeat
%=<<
% memory:
% [#1]: width
% #2 : count
% [#3]: height
% #4 : colour
% [#5]: label
newcommand*memory%>>=
%
begingroup
memory@oargmemory@a
%=<<
newcommand*memory@a[2]%>>=
%
% #1 width
% #2 count
memory@ifnovalF#1memory@width#1relax%
memory@Oargmemory@heightmemory@b#2%
%=<<
newcommand*memory@b[3]%>>=
%
% #1 count
% #2 height
% #3 colour
memory@ifnovalF#2memory@height#2relax%
memory@oargmemory@c#1#3%
%=<<
newcommand*memory@c[3]%>>=
%
% #1 count
% #2 colour
% #3 label
memory@ifnovalTF#3
ensuremathmemory@blocks#1#2
ensuremathunderbracememory@blocks#1#2_text#3%
endgroup
%=<<
makeatother

begindocument
memory8orange%
memory8green[makebox[0pt][Not supported by viewer]]%
memory8yellow%
enddocument

% vim: fdm=marker fmr=>>=,=<<


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago

























answered 7 hours ago









SkillmonSkillmon

26.6k1 gold badge25 silver badges54 bronze badges




26.6k1 gold badge25 silver badges54 bronze badges












  • This is absolutely amazing, right down to the [Not supported by viewer]!

    – Bernardo Meurer
    6 hours ago

















  • This is absolutely amazing, right down to the [Not supported by viewer]!

    – Bernardo Meurer
    6 hours ago
















This is absolutely amazing, right down to the [Not supported by viewer]!

– Bernardo Meurer
6 hours ago





This is absolutely amazing, right down to the [Not supported by viewer]!

– Bernardo Meurer
6 hours ago

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f497431%2fdrawing-a-memory-layout-diagram-with-tikz%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

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367