![如何实现带边框的文本枚举](https://linux22.com/image/364714/%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E5%B8%A6%E8%BE%B9%E6%A1%86%E7%9A%84%E6%96%87%E6%9C%AC%E6%9E%9A%E4%B8%BE.png)
答案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}