9

I would like to get ribbon like the one shown in the picture, with text inside it . Is there an easy way to do this using Tikz or other latex packages, thanks in advance.

enter image description here

4
  • Related: Simulating text on a ribbon
    – Werner
    Jan 14, 2015 at 20:26
  • Thanks i have seen it, but my shape is different and i am newbie with tikz
    – Salim Bou
    Jan 14, 2015 at 20:35
  • Please post an example showing what you have tried or at least not expecting people to start from scratch.
    – cfr
    Jan 15, 2015 at 3:17
  • I've updated my answer with an improved version using a command and a key-value approach. Jan 15, 2015 at 15:52

1 Answer 1

19

Improved version:

enter image description here

Remarks

  1. You have a \Ribbon command with a mandatory argument for the text that goes in the middle part of the ribbon.
  2. I used a key-value approach to easily control the ribbon attributes:

    • color1=<color> controls the color for the "main" part of the ribbon.
    • color2=<color> controls the color for the "shadowed" part of the folds in the ribbon.
    • rblength=<length> controls the length of the ribbon (the total length is 11 timed this dimension).
    • rbheight=<length> controls the height of the ribbon.
    • rbarc=<length> controls the separation between the folds of the ribbon.

    For example, the second ribbon in the image was produced using

    \Ribbon[color1=orange!30,color2=orange!80,rblength=0.5cm,rbheight=2cm]{some` text goes here}\bigskip
    

The code:

\documentclass{article}
\usepackage{tikz}

\colorlet{color1}{gray!40}
\colorlet{color2}{gray}
\newlength\myrblen
\newlength\myrbht
\newlength\myrbarc
\setlength\myrblen{1cm}
\setlength\myrbht{3cm}
\setlength\myrbarc{8pt}

\makeatletter
\define@key{ribbonpar}{color1}{\colorlet{color1}{#1}}
\define@key{ribbonpar}{color2}{\colorlet{color2}{#1}}
\define@key{ribbonpar}{rblength}{\setlength\myrblen{#1}}
\define@key{ribbonpar}{rbheight}{\setlength\myrbht{#1}}
\define@key{ribbonpar}{rbarc}{\setlength\myrbarc{#1}}
\makeatother

\newcommand\Ribbon[2][]{%
\begin{tikzpicture}[thick]
\setkeys{ribbonpar}{#1}
\path
  (0,0) --
  ++(3\myrblen,0) to[out=0,in=0,looseness=3] coordinate[midway] (aux1)
  ++(0,- \myrbarc) --
  ++(-\myrblen,0) to[out=180,in=180,looseness=3] coordinate[midway] (aux2)
  ++(0,- \myrbarc) --
  ++(5\myrblen,0) to[out=0,in=0,looseness=3] coordinate[midway] (aux3)
  ++(0, \myrbarc) --
  ++(-\myrblen,0) to[out=180,in=180,looseness=3] coordinate[midway] (aux4)
  ++(0, \myrbarc) --
  ++(4\myrblen,0) --
  ++(-0.5\myrbht,-0.5\myrbht) --
  ++(0.5\myrbht,-0.5\myrbht) --
  ++(-11\myrblen,0) --
  ++(0.5\myrbht,0.5\myrbht) --
  ++(-0.5\myrbht,0.5\myrbht) --
    cycle;
\draw[fill=color2]
  (aux1) -- ++(0,-0.5\myrbht) coordinate (aux7) -- (aux2|-aux7) -- (aux2|-aux1) -- cycle;  
\draw[fill=color2]
  (aux4) -- ++(0,-0.5\myrbht) coordinate (aux8) -- (aux3|-aux8) -- (aux3|-aux4) -- cycle;  
\draw[thick,fill=color1]
  (0,0) --
  ++(3\myrblen,0) to[out=0,in=0,looseness=3] coordinate[midway] (aux1)
  ++(0,- \myrbarc) --
  ++(-\myrblen,0) to[out=180,in=180,looseness=3] coordinate[midway] (aux2)
  ++(0,- \myrbarc) --
  ++(5\myrblen,0) to[out=0,in=0,looseness=3] coordinate[midway] (aux3)
  ++(0, \myrbarc) --
  ++(-\myrblen,0) to[out=180,in=180,looseness=3] coordinate[midway] (aux4)
  ++(0, \myrbarc) --
  ++(4\myrblen,0) --
  ++(-0.5\myrbht,-0.5\myrbht) --
  ++(0.5\myrbht,-0.5\myrbht) --
  ++(-11\myrblen,0) --
  ++(0.5\myrbht,0.5\myrbht) --
  ++(-0.5\myrbht,0.5\myrbht) --
    cycle;
\path
  (aux2) {[rounded corners=6pt] -- 
  ++(0,\dimexpr-\myrbht-1.5\myrbarc\relax) coordinate (aux5) -- 
  (aux3|-aux5)} -- 
  (aux3);
\fill[color1]
  ([yshift=-\myrbarc]aux2) {[rounded corners=6pt] -- 
  ++(0,\dimexpr-\myrbht-0.5\myrbarc\relax) -- 
  (aux3|-aux5)} -- 
  ([yshift=-\myrbarc]aux3);
\draw
  (aux2) {[rounded corners=6pt] -- 
  ++(0,\dimexpr-\myrbht-1.5\myrbarc\relax) coordinate (aux5) --  
  (aux3|-aux5)} -- 
  (aux3);
\node[
  anchor=north west,
  text width=\dimexpr5\myrblen-\myrbarc\relax,
  align=left,
  ] at ([xshift=\myrbarc,yshift=-\myrbarc]aux2)
  {#2};
\end{tikzpicture}%
}

\begin{document}

\Ribbon{some text goes here}\bigskip

\Ribbon[color1=orange!30,color2=orange!80,rblength=0.5cm,rbheight=2cm]{some text goes here}\bigskip

\Ribbon[color1=cyan!50,color2=cyan,rblength=1.3cm,rbheight=0.8cm,rbarc=5pt]{some text goes here}

\end{document}

First version

A primitive approach:

enter image description here

The code:

\documentclass{article}
\usepackage{tikz}

\colorlet{color1}{gray!40}
\colorlet{color2}{gray}

\begin{document}

\begin{tikzpicture}[thick]
\path
  (0,0) --
  ++(4,0) to[out=0,in=0,looseness=3] coordinate[midway] (aux1)
  ++(0,-8pt) --
  ++(-1,0) to[out=180,in=180,looseness=3] coordinate[midway] (aux2)
  ++(0,-8pt) --
  ++(5,0) to[out=0,in=0,looseness=3] coordinate[midway] (aux3)
  ++(0,8pt) --
  ++(-1,0) to[out=180,in=180,looseness=3] coordinate[midway] (aux4)
  ++(0,8pt) --
  ++(4,0) --
  ++(-1.5,-1.5) --
  ++(1.5,-1.5) --
  ++(-11,0) --
  ++(1.5,1.5) --
  ++(-1.5,1.5) --
    cycle
  ;
\draw[fill=color2]
  (aux1) -- ++(0,-30pt) coordinate (aux7) -- (aux2|-aux7) -- (aux2|-aux1) -- cycle;  
\draw[fill=color2]
  (aux4) -- ++(0,-30pt) coordinate (aux8) -- (aux3|-aux8) -- (aux3|-aux4) -- cycle;  
\draw[thick,fill=color1]
  (0,0) --
  ++(4,0) to[out=0,in=0,looseness=3]
  ++(0,-8pt) --
  ++(-1,0) to[out=180,in=180,looseness=3]
  ++(0,-8pt) --
  ++(5,0) to[out=0,in=0,looseness=3]
  ++(0,8pt) --
  ++(-1,0) to[out=180,in=180,looseness=3]
  ++(0,8pt) --
  ++(4,0) --
  ++(-1.5,-1.5) --
  ++(1.5,-1.5) --
  ++(-11,0) --
  ++(1.5,1.5) --
  ++(-1.5,1.5) --
    cycle
  ;
\path
  (aux2) {[rounded corners=6pt] -- ++(0,-3cm-12pt) coordinate (aux5) -- (aux3|-aux5)} -- (aux3);
\fill[color1]
  ([yshift=-10pt]aux2) {[rounded corners=6pt] -- ++(0,-3cm-2pt) -- (aux3|-aux5)} -- ([yshift=-10pt]aux3);
\draw
  (aux2) {[rounded corners=6pt] -- ++(0,-3cm-12pt) coordinate (aux5) -- (aux3|-aux5)} -- (aux3);
\node[
  anchor=north west,
  text width=4.75cm,
  align=left,
  ] at (3,-22pt)
  {Some text goes here};
\end{tikzpicture}

\end{document}
2
  • Thanks @GonzaloMedina for your smart answer, this is more than I had expected :) .
    – Salim Bou
    Jan 17, 2015 at 18:40
  • How would you modify the code such that the front part of the ribbon (until it bends) is long and the parts at the outside are short? For example, when I use the code to create a ribbon as long as the blue one, I want to have short ends on both sides and a long front ribbon.
    – Taufi
    Nov 14, 2019 at 21:16

You must log in to answer this question.

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