6

I am a newbie to LaTeX and I am trying to use it to create this, but cannot quite figure it out.

enter image description here

Key points, title bar. Can expand vertically. The right edge becomes chamfered. Should expand horizontally to column width. Expands vertically to fit the content.

My current approach using tcolorbox, and TikZ produces this:

enter image description here

This is what my code looks like

\newcommand{\ranked}
{
    \begin{tikzpicture}
    \draw[white, sharp corners] (0.4em,0) -- (0,0.4em) -- (0.4em,0.8em);
    \fill[white, sharp corners] (0.55em, 0) -- (0.15em, 0.4em) -- (0.55em, 0.8em) -- (0.95em, 0.4em);
    \end{tikzpicture}
}
\newcommand{\rankedTalentBox}[3][color-active]
{
  \begin{tcolorbox}[colback=white,colframe=#1,title=#2\hspace*{0pt}\hfill \ranked]
  #3
  \end{tcolorbox}
}

Is there a better approach?

2 Answers 2

10

€dit: simpler.

enter image description here

% Box with Pins  - v2.0 =====
\documentclass{book}
\usepackage[showframe=false]{geometry}
%\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{calc}
\pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}}

% Values 1/2 ===============
\pgfmathsetlengthmacro\frule{1.75pt}
\pgfmathsetlengthmacro\BoxSep{2.5pt}
\pgfmathsetlengthmacro\pin{2*\frule}

\newtcolorbox{mybox}[3][]{      %show bounding box,
% Values 2/2 ===============
width=4.25cm,
colframe=gray, 
colback=white,
colbacktitle=purple,   
% =====================
boxrule=\frule, 
boxsep=\BoxSep, % additional value
top=0pt, left=\BoxSep, right=\BoxSep, 
bottom=\BoxSep+\BoxSep, % some more space for bottom title
enhanced, % allows TikZ etc. 
fontupper=\sffamily,
% Top Title  =======
title=#2, % Title Text
flushleft title,
fonttitle=\color{white}\sffamily\bfseries,
attach boxed title to top={
xshift=0pt,
yshift*=-\BoxSep-\tcboxedtitleheight,
},
boxed title style={    
frame empty, sharp corners,
left=0pt,
boxrule=0pt, 
opacityback=0, % no default fill of title
},     
underlay boxed title={ % manuell styled fill of title: 
\pgfmathsetlengthmacro\s{\tcboxedtitleheight/(2*cos(45))}
\pgfmathsetlengthmacro\h{\s*sin(45)}
\path[fill=tcbcolbacktitle]  (title.north west) rectangle  ([xshift=-\h]title.south east) coordinate(Y1);
\path[fill=tcbcolbacktitle, draw=none] (Y1) -- ++(45:\s) coordinate(Y2) -- ++(135:\s) --cycle;
\node[draw=none, diamond, fill=white, inner sep=0.4*\h] at ([xshift=-\h-1pt]Y2){};
},
% Pin Box  =======
arc is angular,
arc=5pt,
sharp corners=northwest,
finish={ % Pins =======
\path[draw=tcbcolframe, line width=0.75*\pin]  (frame.north) -- +(0,\pin);
\path[draw=tcbcolframe, line width=0.75*\pin]  (frame.south) -- +(0,-\pin);
\path[draw=tcbcolframe, line width=0.75*\pin]  ($(frame.south west)!0.8!(frame.north west)$) -- +(-\pin,0);
% Bottom Title =======
\node[fill=tcbcolbacktitle, draw=none, font=\color{white}\sffamily\footnotesize, outer sep=0pt, 
anchor=center, inner sep=1pt, yshift=0.5*\frule] at ($(frame.south)!0.45!(frame.south east)$) (btitle) {#3}; % Bottom Title Text
\path let \p1=($(btitle.north east)-(btitle.south east)$) in 
\pgfextra{  \pgfmathsetlengthmacro{\H}{sin(45)*veclen(\x1,\y1)}   }
[savevalue={\bh}{\H}];         
\path[fill=tcbcolbacktitle, draw=none]  (btitle.north east) -- +(-45:\bh) -- (btitle.south east) --cycle;
\path[fill=tcbcolbacktitle, draw=none]  (btitle.north west) -- +(225:\bh) -- (btitle.south west)  --cycle;
},
left skip=\pin, #1
}

\begin{document}
\begin{mybox}[]{The Top Title}{Cost 10\$}
Once per round, draw or holster a weapon or item as an incidental.
\end{mybox}
\end{document}
1
  • @GarretGang Good edit ;)
    – cis
    Commented Oct 10, 2020 at 0:38
10

Oooo. @cis just beat me!

With time and patience you can do almost anything with tcolorbox:

\documentclass{article}

\usepackage[sfdefault,condensed]{roboto}
\usepackage[most]{tcolorbox}

\tcbset{active/.style={colbacktitle=red!50!black}}

\newtcolorbox{rankedtalentbox}[3][]{%
  enhanced,
  colback=white,
  colframe=black!50,
  title filled=false,
  titlerule=0pt,
  fonttitle=\bfseries,
  arc is angular,
  arc=6pt,
  sharp corners=northwest,
  text width=3.8cm,
  boxrule=1.5pt,
  left=3pt,
  right=3pt,
  top=3pt,
  bottom=9pt,
  boxsep=1.5pt,
  halign=flush left,
  attach boxed title to top left={
    xshift=3pt,
    yshift*=-3pt-\tcboxedtitleheight},
  boxed title style={
    interior code={},
    frame empty,
    left=0pt,
    boxrule=0pt,
    sharp corners},
  underlay boxed title={
    \path[tcb fill title] 
      (title.north west) --
      ([xshift=-3.5pt-0.5*\tcboxedtitleheight,yshift=-3pt]frame.north east) --
      ([xshift=-3.5pt,yshift=-3pt-0.5*\tcboxedtitleheight]frame.north east) --
      ([xshift=-3.5pt-0.5*\tcboxedtitleheight,yshift=-3pt-\tcboxedtitleheight]frame.north east) --
      (title.south west) -- cycle;
      \path[fill=tcbcoltitle]
      ([xshift=-4pt-0.5*\tcboxedtitleheight,yshift=-4.5pt]frame.north east) --
      ([xshift=-5.5pt,yshift=-3pt-0.5*\tcboxedtitleheight]frame.north east) --
      ([xshift=-4pt-0.5*\tcboxedtitleheight,yshift=-1.5pt-\tcboxedtitleheight]frame.north east) --
      ([xshift=-2.5pt-\tcboxedtitleheight,yshift=-3pt-0.5*\tcboxedtitleheight]frame.north east) --
      cycle;
      \path[draw=tcbcolframe,line width=1.5pt] (frame.north) -- ++(0,3pt);
      \path[draw=tcbcolframe,line width=1.5pt] (frame.south) -- ++(0,-3pt);
      \path[draw=tcbcolframe,line width=1.5pt] ([xshift=-3pt]title.west) -- ++(-3pt,0);
      \path[tcb fill title]
        ([xshift=-7.5pt,yshift=0.75pt]frame.south east) -- ++(135:4pt) --
        ++(-1.5cm,0) -- ++(-135:4pt) -- ++(-45:4pt) -- ++(1.5cm,0) -- cycle
        [insert path={node[font=\tiny,text=tcbcoltitle]
          at (current path bounding box.center) {COST #3}}];
  },
  active,
  title=#2,
  #1
}

\begin{document}

\begin{rankedtalentbox}{QUICK DRAW}{10}
  Once per round draw or holster a weapon or item as an incidental.
\end{rankedtalentbox}

\end{document}

output

1
  • All the codes of this question are very nice...Excellent work. You have chosen the exact color.
    – Sebastiano
    Commented Oct 1, 2020 at 19:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .