0

I was wondering if it's possible to somehow create similar structures in LyX:

enter image description here

The colors does not mean to me, but to know how to create the cool structures will be great.

Tried to find similar threads but without any success. Also tried to read the tikz documentation to see if its possible to achieve it.

2
  • 1
    And what has your reading of the TikZ documentation shown? Actually that's quite a basic task…
    – TeXnician
    Commented Feb 24, 2019 at 12:45
  • You don't need a hammersledge like TikZ for that.A simple tabular with colortbl will do.
    – Bernard
    Commented Feb 24, 2019 at 12:50

2 Answers 2

1

Very short approximation:

memory

\documentclass{article}
\usepackage{tikz}

\newcommand\xoutofeight[2][black]{%
    \begin{tikzpicture}
        \pgfmathsetlengthmacro\xstep{.6cm}
        \pgfmathsetlengthmacro\ystep{\baselineskip}
        \fill[#1!40] (0,0) rectangle ({#2*\xstep},\ystep);
        \draw[#1,xstep=\xstep,ystep=\ystep] (0,0) grid ({8*\xstep},\ystep);
    \end{tikzpicture}}

\begin{document}
    short num: \xoutofeight{2}

    char* str: \xoutofeight{8}

    short num: \xoutofeight[green!80!black]{2}
\end{document}
1

Simple tabulars with xcolor and array can do that:

\documentclass{article}
\usepackage{array}
\usepackage[table, svgnames]{xcolor}

\begin{document}

    \begin{center}
\setlength{\arrayrulewidth}{1.5pt}
\begin{tabular}{|*{8}{p{0.5cm}|}}
  \hline
  \rowcolor{WhiteSmoke!60!Lavender}& & & & & & &\rule{0pt}{1.5cm} \\
  \hline
\end{tabular}\vskip 1cm

\begin{tabular}{|*{2}{>{\columncolor{WhiteSmoke!60!Lavender}}p{0.5cm}|}*{6}{p{0.5cm}|}}
  \hline
  & & & & & & &\rule{0pt}{1.5cm} \\
  \hline
\end{tabular} \end{center}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .