答案1
A蒂克兹解决方案:
\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}
抱歉,颜色选择不正确!:)
答案2
tcolorbox
环境开始一个新行,\tcbox
不能并且可以在一行中一个接一个地放置等等。
这些选项尝试获得外观(将颜色等更改为一种感觉)并应用equal height group
以保证盒子具有相同的高度 - 为此编译两次以便在此处获得正确的高度!)
另请参阅如何通过向宏添加选项来更改本地框\codebox
。
\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}