3

I want to make something like this enter image description here

so far I have this

enter image description here

How can I make only one rectangle in the third row (0-8) and how can I write the numbers above the rectangles and only in the first rectangle a letter and colour the first rectangle grey?

This is my code

 \documentclass[titlepage=true, 12pt]{scrartcl}

    \usepackage[ngerman]{babel}
    \usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}

    \usepackage{newtxtext,newtxmath}
    \setkomafont{disposition}{\normalfont\bfseries}

    \usepackage[utf8]{inputenc}

    \setlength{\parskip}{1.2ex}
    \setlength{\parindent}{0em}

    \usepackage{fancyhdr}
    \pagestyle{fancy}

    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \fancyhead[L]{Name}
    \fancyfoot[C]{\thepage}


    \usepackage{filecontents}
    \usepackage[autostyle]{csquotes}

    \usepackage{setspace}

    \usepackage{tabularx}

    \usepackage{adjustbox}

    \usepackage{tikz}
    \usetikzlibrary{shapes.geometric}

    \begin{document}

    \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
    \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
    \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

    \setlength{\extrarowheight}{5pt}
    \setlength{\tabcolsep}{6pt}

    \adjustbox{valign=t}{\begin{minipage}[t]{0.63\textwidth}

    \begin{tabular}{|C{0.8cm}|L{8cm}|}

    \hline
    A & peu de cours \\
    \hline
    B &  la confiance en soi\\
    \hline
    C &  se trouve le village du Père Noël \\
    \hline
    D & début de semestre\\
    \hline
    E &  à augmenter la fréquentation de la ville\\
    \hline
    F & des ours polaires \\
    \hline
    G & fin de semestre\\
    \hline
    H & beaucoup de cours \\
    \hline
    I & nous a permis de nous intégrer plus facilement \\
    \hline
    J & une magnifique aurore boréale \\
    \hline
    K & les gens sont quasiment tous bilingues en anglais \\
    \hline
    \end{tabular}

    \end{minipage}}
    \adjustbox{valign=t}{\begin{minipage}[t]{0.36\textwidth}
    \def\m{40pt}
    \begin{tikzpicture}[
        square/.style={draw,regular polygon,regular polygon sides=4,minimum size=\m},
        outer sep=0,inner sep=0]
        \def\w{3}
        \def\h{3}

      \foreach \x in {0,1,2,3}
        \foreach \y in {1,...,\h}
           {\pgfmathtruncatemacro{\label}{(\y-1) * \w + \x}
           \node [square]  (\x,\y) at (\x*\m,-\y*\m) {\label};
           }
    \end{tikzpicture}
    \end{minipage}}


    \end{document}
5

Something like this? Short & sweet.

\documentclass{article}
\usepackage{xcolor,stackengine}
\newcommand\splat[3][white]{%
  \colorbox{#1}{~~\sffamily\stackon{\fbox{\makebox[3ex]{\large\strut #2}}}{#3}~~}%
}\begin{document}
\Shortstack[l]{
\splat[gray!20]{F}{0}\splat{}{1}\splat{}{2}\splat{}{3}
\splat{}{4}\splat{}{5}\splat{}{6}\splat{}{7}
\splat{}{8}}
\end{document}

enter image description here

4

To ignore the nineth box, just check for \label being equal to 9. To put the text above I use label={above:\label} and leave the node text empty.

\documentclass[12pt]{scrartcl}

\usepackage{tabularx}
\usepackage{adjustbox}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

\setlength{\extrarowheight}{5pt}
\setlength{\tabcolsep}{6pt}

\adjustbox{valign=t}{\begin{minipage}[t]{0.63\textwidth}

    \begin{tabular}{|C{0.8cm}|L{8cm}|}

      \hline
      A & peu de cours \\
      \hline
      B &  la confiance en soi\\
      \hline
      C &  se trouve le village du Père Noël \\
      \hline
      D & début de semestre\\
      \hline
      E &  à augmenter la fréquentation de la ville\\
      \hline
      F & des ours polaires \\
      \hline
      G & fin de semestre\\
      \hline
      H & beaucoup de cours \\
      \hline
      I & nous a permis de nous intégrer plus facilement \\
      \hline
      J & une magnifique aurore boréale \\
      \hline
      K & les gens sont quasiment tous bilingues en anglais \\
      \hline
    \end{tabular}

  \end{minipage}}
\adjustbox{valign=t}{\begin{minipage}[t]{0.36\textwidth}
    \def\m{40pt}
    \begin{tikzpicture}[
      square/.style={
        draw,regular polygon,regular polygon sides=4,minimum size=\m
      },
      outer sep=1pt,inner sep=0]
      \def\w{3}
      \def\h{3}

      \foreach \x in {0,1,2,3}
        \foreach \y in {1,...,\h}
        {
          \pgfmathtruncatemacro{\label}{(\y-1) * \w + \x}
          \ifnum\label=9\else
            \node [square,label={above:\label}] (\x,\y) at (\x*\m,-\y*\m) {};
          \fi
        }
    \end{tikzpicture}
  \end{minipage}}

\end{document}

enter image description here

  • How can I fix the problem that the row ends with 3 and the next one starts with 3 instead of 4. – Katharina May 22 '17 at 11:11
3

I had to stretch it a bit, but you can use label=[above:\label]. You can remove the text inside of the nodes on your own.

square

 \documentclass[titlepage=true, 12pt]{scrartcl}

    \usepackage[ngerman]{babel}
    \usepackage[a4paper, text={16.5cm, 25.2cm}, centering]{geometry}

    \usepackage{newtxtext,newtxmath}
    \setkomafont{disposition}{\normalfont\bfseries}

    \usepackage[utf8]{inputenc}

    \setlength{\parskip}{1.2ex}
    \setlength{\parindent}{0em}

    \usepackage{fancyhdr}
    \pagestyle{fancy}

    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \fancyhead[L]{Name}
    \fancyfoot[C]{\thepage}


    \usepackage{filecontents}
    \usepackage[autostyle]{csquotes}

    \usepackage{setspace}

    \usepackage{tabularx}

    \usepackage{adjustbox}

    \usepackage{tikz}
    \usetikzlibrary{shapes.geometric}

    \begin{document}

    \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
    \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
    \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}

    \setlength{\extrarowheight}{5pt}
    \setlength{\tabcolsep}{6pt}

    \adjustbox{valign=t}{\begin{minipage}[t]{0.63\textwidth}

    \begin{tabular}{|C{0.8cm}|L{8cm}|}

    \hline
    A & peu de cours \\
    \hline
    B &  la confiance en soi\\
    \hline
    C &  se trouve le village du Père Noël \\
    \hline
    D & début de semestre\\
    \hline
    E &  à augmenter la fréquentation de la ville\\
    \hline
    F & des ours polaires \\
    \hline
    G & fin de semestre\\
    \hline
    H & beaucoup de cours \\
    \hline
    I & nous a permis de nous intégrer plus facilement \\
    \hline
    J & une magnifique aurore boréale \\
    \hline
    K & les gens sont quasiment tous bilingues en anglais \\
    \hline
    \end{tabular}

    \end{minipage}}
    \adjustbox{valign=t}{\begin{minipage}[t]{0.36\textwidth}
    \def\m{40pt}
    \begin{tikzpicture}[
        square/.style={draw,regular polygon,regular polygon sides=4,minimum size=\m},
        outer sep=0,inner sep=0]
        \def\w{3}
        \def\h{3}

      \foreach \x in {0,1,2,3}
        \foreach \y in {1,...,\h}
           {\pgfmathtruncatemacro{\label}{(\y-1) * \w + \x}
           \node [square,label={[label distance=.1cm]above:\label}]  (\x,\y) at (\x*\m,-\y*\m*1.2) {\label};
           }
    \end{tikzpicture}
    \end{minipage}}


    \end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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