Another idea (not yet packaged in a command) with a sidebyside
tcolorbox
\documentclass[border=1mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\hypersetup{pdfborder={0 0 0}}
\RequirePackage[usenames,tables]{xcolor}
\definecolor{ABlue}{HTML}{127bca}
\definecolor{LHScolor}{HTML}{555555}
% --------------------
% Text blocks
% --------------------
\usepackage[most]{tcolorbox}
\tcbset
{
enhanced,top=0pt,left=0pt,right=0pt,bottom=0pt,
enhanced,hbox,bicolor,sidebyside,
colback=LHScolor,colbacklower=ABlue,
fontupper=\color{white},fontlower=\color{white},
lefthand width=1em,
width=10em,
size=small,boxrule=0pt,rounded corners
}
\begin{document}
\begin{tcolorbox}[]
DOI
\tcblower
1234/5678
\end{tcolorbox}
\end{document}
EDIT : An improved version with automatic computation of box dimensions, color shading and \newcommand
definition
\documentclass[border=1mm]{standalone}
\usepackage[utf8]{inputenc}
\RequirePackage[usenames,tables]{xcolor}
\definecolor{ABlue}{HTML}{127bca}
\definecolor{LHScolor}{HTML}{555555}
% --------------------
% Text blocks
% --------------------
\usepackage[most]{tcolorbox}
\newcommand{\DOIbox}[1]{
\tcbsidebyside[
bicolor,
sidebyside,
%fontupper=\color{white},fontlower=\color{white},% <-- broken by sidebyside adapt (explicitely set in input)
sidebyside adapt=both,
sidebyside gap=5pt,
top=0pt,left=0pt,right=0pt,bottom=0pt,
boxrule=0pt,rounded corners,
interior style={top color=LHScolor,bottom color=LHScolor!60!black},
segmentation style={top color=ABlue,bottom color=ABlue!60!black},
]{%
\color{white}DOI%
}{%
\color{white}#1%
}%
}
\begin{document}
\DOIbox{1}
\DOIbox{12}
\DOIbox{123}
\DOIbox{1234}
\DOIbox{12345}
\end{document}
EDIT n°2 (hopefully final one) Addition of a drop shadow (thanks to @Eric Marsden for the idea and motivation).
\documentclass[border=1mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[scaled]{helvet}
\renewcommand*{\familydefault}{\sfdefault}
\RequirePackage[usenames,tables]{xcolor}
\definecolor{ABlue}{HTML}{127bca}
\definecolor{LHScolor}{HTML}{555555}
\usepackage{graphicx}
% --------------------
% Text blocks
% --------------------
\usepackage[most]{tcolorbox}
% Creation of a dropped shadow
\newcommand{\droptextshadow}[2]{%
\tikz[baseline,outer sep=0pt, inner sep=0pt]{
% Dropped Shadow
\node[#1!40!black] at (0,-0.2ex) {#2};
% Text
\node[white] at (0,0) {#2};
}%
}
\newcommand{\DOIbox}[1]{
\tcbsidebyside[
bicolor,
sidebyside,
%fontupper=\color{white},fontlower=\color{white},% <-- broken by sidebyside adapt (explicitely set in input)
sidebyside adapt=both,
sidebyside gap=5pt,
top=0pt,left=0pt,right=0pt,bottom=0pt,
boxrule=0pt,rounded corners,
interior style={top color=LHScolor,bottom color=LHScolor!60!black},
segmentation style={top color=ABlue,bottom color=ABlue!60!black},
]{%
\droptextshadow{LHScolor}{DOI}% <-- Drop shadow + text for DOI
}{%
\droptextshadow{ABlue}{#1}% <-- Drop shadow + text for reference number
}%
}
\begin{document}
\DOIbox{10.5281/zenodo.241372}
\end{document}
EDIT n°3 Addition of hyperref
with option hidelinks
to make the box clickable and slight shadow settings modification to reduce shadow footprint
\documentclass[border=1mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[scaled]{helvet}
\renewcommand*{\familydefault}{\sfdefault}
\RequirePackage[usenames,tables]{xcolor}
\definecolor{ABlue}{HTML}{127bca}
\definecolor{LHScolor}{HTML}{555555}
\usepackage[hidelinks]{hyperref}
% --------------------
% Text blocks
% --------------------
\usepackage[most]{tcolorbox}
% Creation of a dropped shadow
\newcommand{\droptextshadow}[2]{%
\tikz[baseline,outer sep=0pt, inner sep=0pt]{
% Dropped Shadow
\node[#1!40!black] at (0,-0.1ex) {#2};
% Text
\node[white] at (0,0) {#2};
}%
}
\newcommand{\DOIbox}[1]{
\tcbsidebyside[
bicolor,
sidebyside,
%fontupper=\color{white},fontlower=\color{white},% <-- broken by sidebyside adapt (explicitely set in input)
sidebyside adapt=both,
sidebyside gap=5pt,
top=0pt,left=0pt,right=0pt,bottom=0pt,
boxrule=0pt,rounded corners,
interior style={top color=LHScolor,bottom color=LHScolor!60!black},
segmentation style={top color=ABlue,bottom color=ABlue!60!black},
]{%
\droptextshadow{LHScolor}{DOI}% <-- Drop shadow + text for DOI
}{%
\droptextshadow{ABlue}{\href{http://dx.doi.org/#1}{#1}}% <-- Drop shadow + text for reference number + hyperref
}%
}
\begin{document}
\DOIbox{10.5281/zenodo.241372}
\end{document}
\strut
to before#3
of\fcolorbox
so they are the same height.wget
orcurl
from LaTeX to download the PNGs from shields.io during compilation. However, you have to run it aslatex --shell-escape
for this to work.