Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a document that explains internals of memory buffers and computers and I'm looking for a LaTeX package that would allow me to create diagrams similar to the following:

Circular buffer:

enter image description here

Linear buffer:

enter image description here

Any suggestions?

share|improve this question
1  
You can use TikZ to draw this and much more. –  Martin Scharrer May 16 '11 at 16:30
2  
For the ring buffer you should be able to adept the answers to How can I produce a 'ring (or wheel) chart'. –  Martin Scharrer May 16 '11 at 16:32
    
Thanks. There both look great. –  Phonon May 16 '11 at 16:35
    
@Martin Dude! This is amazing! Thanks! = ) –  Phonon May 16 '11 at 18:50
    
You are welcome. I personally would keep the '4 bytes in FIFO' text upright. You just need to change sloped,above,allow upside down to right. –  Martin Scharrer May 16 '11 at 18:57

1 Answer 1

up vote 9 down vote accepted

You can draw such diagrams with TikZ (tikz package plus libraries) or PS-Tricks (pstricks and other pst- packages). I personally would recommend TikZ.

Here is how I would draw these diagrams:

\documentclass{article}

\usepackage{tikz}

\begin{document}
\sffamily
\textbf{Circular buffer:}

\begin{tikzpicture}[>=latex,font=\sffamily,semithick,scale=1.75]
    \fill [green!25] (0,0) -- (67.5:1) arc [end angle=-22.5, start angle=67.5, radius=1] -- cycle;
    \draw [thick] (0,0) circle (1);
    \foreach \angle in {90,67.5,...,-67.5}
        \draw (\angle:1) -- (\angle-180:1);
    \node [circle,thick,fill=white,draw=black,align=center,minimum size=3cm] at (0,0) {FIFO as a\\Circulate Buffer};
    \draw [<-] (56.25:1) -- (56.25:1.25) -- +(.333,0)
        node [right,inner xsep=.333cm] (Head) {Head (extract)};
    \draw [<-] (-33.75:1) -- (-33.75:1.25) -- +(.333,0)
        node [right,inner xsep=.333cm] (Tail) {Tail (insert)};
    \draw [->,shorten >=5pt,shorten <=5pt] (Tail.west) to [bend right] 
        node [midway,sloped,above,allow upside down] {\footnotesize 4\,bytes in FIFO}
    (Head.west);
\end{tikzpicture}

\bigskip
\bigskip

\textbf{Linear buffer:}
\par
\bigskip

\begin{tikzpicture}[>=latex,font=\sffamily,every node/.style={minimum width=1cm,minimum height=1.5em,outer sep=0pt,draw=black,fill=blue!40,semithick}]
        \node at (0,0) (A) {};
        \node [anchor=west] at (A.east) (B) {};
        \node [anchor=west] at (B.east) (C) {1};
        \node [anchor=west] at (C.east) (D) {2};
        \node [anchor=west] at (D.east) (E) {3};
        \node [anchor=west] at (E.east) (F) {};
        \node [anchor=west] at (F.east) (G) {};
        \draw [->,shorten >=2pt,shorten <=2pt,semithick] (G.south) -- +(0,-1em) -| (A);
\end{tikzpicture}
\end{document}

Result

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.