Duplicating shields.io badges

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}

enter image description here

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}

enter image description here

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}

enter image description here

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}

enter image description here


Here's a version that attempts to reproduce the color gradient and font shadow effects of the Zenodo badges. The color gradient is not rendered as well as in the SVG versions, unfortunately.

\documentclass{article}
\usepackage{fontspec}
\usepackage{relsize}
\usepackage{libertine}
\usepackage{calc}
\usepackage{tikz}
\usepackage[margin=1cm]{geometry}
\usetikzlibrary{calc,positioning}

\newlength{\doiLength}

%% shield as per https://zenodo.org/badge/doi/10.5281/zenodo.241372.svg
\newcommand{\DOIShield}[1]{
  \settowidth{\doiLength}{#1}
  \raisebox{-0.6ex}{%
  \begin{tikzpicture}[anchor=base,baseline]
    \node (doi) {\includegraphics[width=1.2\doiLength{}+3em]{doi-shield}};
    \node[right=2em+0.12\doiLength of doi.west,font={\fontspec{DejaVu Sans}\selectfont\smaller}] (n) {#1};
    \node[font={\fontspec{DejaVu Sans}\selectfont\smaller},anchor=south
      west,xshift=0.005em,yshift=0.007em] at (n.south west) {\color{white}{#1}};
  \end{tikzpicture}}}

\begin{document}
Foo \DOIShield{10.5281/zenodo.241372}.

\Huge
Bar \DOIShield{10.1016/0090-2616(77)90044-4}.
\end{document}

Example output: Example DOI badges

where the file doi-shield.pdf is simply a conversion of a Zenodo SVG shield to PDF, with the DOI component deleted.


Add a \strut to before #3 of \fcolorbox so they are the same height.

Tags:

Graphics

Icon