4

How to achieve a layout just like the attached image. I have tried already using tcolorbox but the items are shown one per line.

\newcommand{\codebox}[1]{\ttfamily\hyphenchar\font=45{
\begin{tcolorbox}[hbox]{#1}\end{tcolorbox}}}

enter image description here

  • Welcome to TeX.SE. tcolorbox environments start a new line, \tcbox commands doesn't – user31729 Nov 1 '17 at 17:56
  • The word enumeration is wrong here, in my point of view – user31729 Nov 1 '17 at 18:45
8

A tikz solution:

enter image description here

\documentclass{article}
\usepackage{tikz}

\tikzset{codebox/.style={% set whatever defaults you want for the style
    rounded corners,
    fill=blue,
    text=white,
    rectangle,
    inner sep=1mm,
    minimum height=5mm,
    font=\ttfamily
  }
}

% usage: \codebox[optional style]{text}
\newcommand{\codebox}[2][]{\tikz{\node[codebox,#1]at(0,0){#2};)}}

\begin{document}

  \codebox{Swift} \codebox{Objective-c}
  \codebox[fill=red]{MySQL} \codebox[fill=green]{Python}

\end{document}

Apologies for the choice of colours! :)

8

tcolorbox environments start a new line, \tcbox doesn't and can be placed one after another one in a line etc.

The options try to get the look (change the color etc. to one feelings) and apply equal height group in order to guarantee that the boxes have the same height -- compile twice for this in order to get the correct heights here!)

See also how local boxes can be changed by adding options to the \codebox macro.

\documentclass{article}

\usepackage[most]{tcolorbox}


\definecolor{blueboxcolor}{rgb}{0.28,0.52,0.77}% Kolorpicker from KDE suggests this color mixture

\tcbset{%
  bluecolorbox/.style={
  enhanced,  
  frame hidden, 
  colback=blueboxcolor,
  colupper=white,
  nobeforeafter,
  boxsep=0pt,
  arc=4pt,
  auto outer arc,
  halign=center,
  fontupper=\ttfamily\LARGE\bfseries
}
}


\newtcbox{\codebox}[1][]{
  bluecolorbox,
  equal height group,
  #1,
}


\begin{document}
\parindent=0em
\codebox{Swift} \codebox{Objective C} \codebox{Java} \codebox{C++} \codebox{\LaTeXe} \codebox{Fortran 54} \codebox{Algol} \codebox{Pascal} \codebox{QBasic} \codebox{HTML} \codebox[colback=yellow!60,colupper={blue}]{\TeX} \codebox{Eiffel}

\end{document}

enter image description here

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.