2

I have the following within a class:

\newcommand{\blacknode}[1]{
\begin{tikzpicture}
\node[draw, fill=black, text=white, rectangle, rounded corners, node distance=1mm, inner sep=5pt] %, align=center %5mm
  {#1};
\end{tikzpicture}
}

When I use this in my script:

\blacknode{Python}
\blacknode{Matlab}
\blacknode{VBA}
\blacknode{\LaTeX}
\blacknode{Javascript}
\blacknode{C}
\blacknode{Ladder Logic}
\blacknode{R}
\blacknode{STL}
\blacknode{Arduino}

This is my output:

Example

How can I better the format? More compact/dynamic packing and the same height? Is there a better option than using nodes?

8
  • 2
    Please make your example code compilable. Also, how exactly should the output look like?
    – leandriis
    Jun 12, 2020 at 10:58
  • 1
    In order to get boxes with equal heights, you could add minimum height=0.7cm.
    – leandriis
    Jun 12, 2020 at 11:00
  • @leandriis Apologies, coming from StackOverflow not too familiar with LaTeX Exchange nuances -- I would like to remove the horizontal spacing between nodes Jun 12, 2020 at 11:00
  • 1
    Do you currently use your \blacknode commands inside of any other kind of environment? The linewidth seems quite narroe and I get a different output if I simply place your code in a standard article class. A complete minimal working example (MWE) would help clarify this.
    – leandriis
    Jun 12, 2020 at 11:04
  • 1
    @Zarko I am trying to, but as a beginner, it is difficult to minimize the class and the document - Hopefully, get it done soon - Thank you Jun 12, 2020 at 11:58

4 Answers 4

3

Not too elegant but probably closer to the desired output:

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\tikzset{blacknode/.style={draw, 
                          fill=black, 
                          text=white, 
                          rectangle, 
                          rounded corners, 
                          inner sep=5pt, 
                          minimum height=0.7cm,
                          }}


\begin{tikzpicture}[every node/.style={blacknode}]
\node(python){Python};
\node[right= 0.1cm of python](matlab){Matlab};
\node[below=0.8cm of python.west, anchor=west](vba){VBA};
\node[right=0.1cm of vba](latex){\LaTeX};
\node[below=0.8cm of vba.west,anchor=west](javascript){Javascript};
\node[right=0.1cm of javascript](c){C};
\node[below=0.8cm of javascript.west,anchor=west](ladderlogic){Ladder Logic};
\node[below=0.8cm of ladderlogic.west,anchor=west](r){R};
\node[right=0.1cm of r](stl){STL};
\node[right=0.1cm of stl](arduino){Arduino};
\end{tikzpicture}
\end{document}
1
  • Very much appreciated - wonderfully done thank you. Jun 12, 2020 at 12:01
5

Another suggestion with tcbox (from tcolorbox)

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}

\newtcbox{\blacknode}[1][black]{%
on line, colback=#1, colframe=#1, colupper=white, equal height group = blacknode, before upper=\strut, boxsep=0pt}


\begin{document}

\noindent\blacknode{Python}
\blacknode{Matlab} \\
\blacknode{VBA}
\blacknode{\LaTeX}\\
\blacknode{Javascript}
\blacknode{C}\\
\blacknode[blue!70!black]{Ladder Logic}
\blacknode{R}\\
\blacknode{STL}
\blacknode[red]{Arduino}

\end{document}

enter image description here

3

Another way of doing the same thing -- matrix

enter image description here

\begin{tikzpicture}[
%                        node distance=5mm,
                        terminal/.style={
                        % The shape:
                        rectangle,
                        minimum size=10mm,
                        rounded corners=3mm,
                        % The rest
                        very thick,
                        draw=black!50,
                        fill=black, 
                        text=white, 
                        inner sep=5pt,
                        font=\ttfamily}
                        ]
                        
        \matrix[
        row sep=6pt,
        column sep=2pt]{
        %first row
        \node (digit1) [terminal] {A};&
               \node (digit1) [terminal] {Ap};&
                      \node (digit1)[terminal] {App};&&\\
        %second row
        \node (digit1) [terminal] {Appl};&
               \node (digit2) [terminal] {Apple};&&
                      \node(digit3) [terminal] {A};&\\
        };
        
    \end{tikzpicture}
1

One more example:

enter image description here

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
    node distance = 0mm,
every node/.style = {draw, rounded corners, fill=black, text=white, 
                     text height=3ex, text depth=0.5 ex, 
                     outer sep=1mm}
                    ]
\node (n1)                                  {Python};
\node (n2) [below right=of n1.south west]   {Matlab};
\node (n3) [below right=of n2.south west]   {VBA};
\node (n4) [right=of n3]                    {\LaTeX};
\node (n5) [below right=of n3.south west]   {Javascript};
\node (n6) [right=of n5]                    {C};
\node (n7) [below right=of n5.south west]   {Ladder Logic};
\node (n8) [below right=of n7.south west]   {R};
\node (n9) [right=of n5]                    {STL};
\node (n10)[below right=of n8.south west]   {Arduino};    
    \end{tikzpicture}
\end{document}

You must log in to answer this question.

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