1

I refer to this answer for drawing a ribbon with variable bending points. Based on the code of Schrödinger's cat, I cannot produce a white ribbon when using the background package at the same time. The following code produces a (supposedly) white ribbon based on Schrödinger's cat's answer with minor changes and in combination with the background package. The background image used can be found here. The result, however, is a transparent but not white ribbon showing the background image. I guess I'd need to force the ribbon to overlay the background image, but do not know how to adjust the code to reflect that.

\documentclass[a0, landscape]{sciposter} 
\usepackage[all]{genealogytree}               
\usepackage{graphicx}                        
\usepackage{yfonts}
\usepackage{suetterl}
\usepackage{txfonts}
\usepackage{tikz}
\usepackage{pagecolor} 
\usepackage[pages=some]{background}


\backgroundsetup{
    scale=1,
    color=black,
    opacity=0.6,
    angle=0,
    contents={%
        \includegraphics[width=\paperwidth,height=\paperheight]{Tigerramki}
    }%
    hshift = -3cm, % horizontal margin
    vshift = -3cm  % vertical margin
}


\usetikzlibrary{calc}
\tikzset{pics/ribbon/.style={code={
            \def\pv##1{\pgfkeysvalueof{/tikz/ribbon/##1}}
            \node[alias=aux,/tikz/ribbon/node]{#1};
            \fill[\pv{shadow color}]
            (aux.north west) arc(-90:-270:\pv{arc radius}) 
            -- ++ (\pv{inset},0) arc(-90:00:\pv{arc radius})
            -- ([xshift=\pv{inset}+\pv{arc radius}]aux.north west)
            (aux.north east) arc(-90:90:\pv{arc radius}) 
            -- ++ (-\pv{inset},0) arc(-90:-180:\pv{arc radius})
            -- ([xshift=-\pv{inset}-\pv{arc radius}]aux.north east);
            \draw let \p1=($(aux.north)-(aux.south)$) in 
            % little stretch south west
            (aux.south west) arc(-90:-180:\pv{arc radius}) -- ++ (0,\y1)
            % big stretch north west 
            (aux.north west) arc(-90:-270:\pv{arc radius}) 
            -- ++ (\pv{inset},0) arc(-90:90:\pv{arc radius}) 
            -- ++ (-\pv{outset},0) -- ++(\y1/2,-\y1/2)
            -- ++(-\y1/2,-\y1/2) -- 
            ([yshift=4*\pv{arc radius},xshift=-\pv{arc radius}]aux.south west)
            % little stretch south east
            (aux.south east) arc(-90:0:\pv{arc radius}) -- ++ (0,\y1)
            % big stretch north east 
            (aux.north east) arc(-90:90:\pv{arc radius}) 
            -- ++ (-\pv{inset},0) arc(-90:-270:\pv{arc radius}) 
            -- ++ (\pv{outset},0) -- ++(-\y1/2,-\y1/2)
            -- ++(\y1/2,-\y1/2) -- 
            ([yshift=4*\pv{arc radius},xshift=\pv{arc radius}]aux.south east)
            % top
            (aux.north west) -- (aux.north east)
            % bottom
            (aux.south west) -- (aux.south east);
    }},
    ribbon/.cd,node/.style={align=center,inner xsep=5pt},%<- controls the node options
    arc radius/.initial=2pt,%<- self-explaining (?)
    inset/.initial=1cm,%<- horizontal distance of the lower horizontal stretches
    outset/.initial=2cm,%<- horizontal distance of the upper horizontal stretches
    outer/.style={draw},%<- left and right band of the ribbon
    shadow color/.initial=gray!80}%<- self-explaining (?)
\newcommand{\TikZRibbon}[2][]{\begin{tikzpicture}
    \tikzset{ribbon/.cd,#1}
    \pic{ribbon={#2}};
    \end{tikzpicture}}


\begin{document} 
    \pagecolor{white} 
    \BgThispage


\begin{center} \TikZRibbon[node/.append style={font=\Huge,inner xsep=5em},inset=2cm,outset=5cm, outer/.append style={fill=white}]{%
    This ribbon should be white but it's not~} 
\end{center} 

\end{document} 

enter image description here

Taufi
  • 379

1 Answers1

1

I think there was a slight misunderstanding in the discussion below this post. There were two different ribbons at work, a more basic one, the upper version, and a more fancy version, the lower code. The fancier version can be filled.

\RequirePackage{xcolor}
\documentclass[a0, landscape]{sciposter} 
% the following packages are not used in the MWE 
%\usepackage[all]{genealogytree}               
%\usepackage{graphicx}                        
%\usepackage{yfonts}
%\usepackage{suetterl}
%\usepackage{txfonts}
%\usepackage{pagecolor} 
\usepackage[pages=some]{background}
\usepackage{tikz}


\backgroundsetup{
    scale=1,
    color=black,
    opacity=0.6,
    angle=0,
    contents={%
\includegraphics[width=\paperwidth,height=\paperheight]{example-image-duck}
    }%
    hshift = -3cm, % horizontal margin
    vshift = -3cm  % vertical margin
}


\usetikzlibrary{calc}
\tikzset{pics/ribbon/.style={code={
\def\pv##1{\pgfkeysvalueof{/tikz/ribbon/##1}}
\node[alias=aux,/tikz/ribbon/node]{#1};
\path[ribbon/shadow]
(aux.north west) arc(-90:-270:\pv{arc radius})
-- ++ (\pv{inset},0) arc(-90:00:\pv{arc radius})
-- ([xshift=\pv{inset}+\pv{arc radius}]aux.north west);
\path[ribbon/shadow] (aux.north east) arc(-90:90:\pv{arc radius})
-- ++ (-\pv{inset},0) arc(-90:-180:\pv{arc radius})
-- ([xshift=-\pv{inset}-\pv{arc radius}]aux.north east);
\path[ribbon/outer] let \p1=($(aux.north)-(aux.south)$) in
% little stretch south west
(aux.south west) arc(-90:-180:\pv{arc radius}) -- ++ (0,\y1)
arc(180:270:\pv{arc radius}) -- cycle
% little stretch south east
(aux.south east) arc(-90:0:\pv{arc radius}) -- ++ (0,\y1)
arc(0:-90:\pv{arc radius}) --cycle;
\path[ribbon/back] let \p1=($(aux.north)-(aux.south)$) in
% big stretch north west
([xshift=-\pv{arc radius},yshift=\pv{arc radius}]aux.north west) arc(180:90:\pv{arc radius})
-- ++ (\pv{inset},0) arc(-90:90:\pv{arc radius})
-- ++ (-\pv{outset},0) -- ++(\y1/2,-\y1/2)
-- ++(-\y1/2,-\y1/2) --
([yshift=4*\pv{arc radius},xshift=-\pv{arc radius}]aux.south west)
-- cycle
% big stretch north east
([xshift=\pv{arc radius},yshift=\pv{arc radius}]aux.north east)
arc(0:90:\pv{arc radius})
-- ++ (-\pv{inset},0) arc(-90:-270:\pv{arc radius})
-- ++ (\pv{outset},0) -- ++(-\y1/2,-\y1/2)
-- ++(\y1/2,-\y1/2) --
([yshift=4*\pv{arc radius},xshift=\pv{arc radius}]aux.south east)
-- cycle
% top
(aux.north west) -- (aux.north east)
% bottom
(aux.south west) -- (aux.south east);
}},
ribbon/.cd,node/.style={align=center,inner xsep=5pt},%<- controls the node options
arc radius/.initial=3pt,%<- self-explaining (?)
inset/.initial=1cm,%<- horizontal distance of the lower horizontal stretches
outset/.initial=2cm,%<- horizontal distance of the upper horizontal stretches
back/.style={draw},%<-ribbon pieces in the background
outer/.style={draw},%<- left and right band of the ribbon
shadow/.style={fill=gray!80}}%<- self-explaining (?)
\newcommand{\TikZRibbon}[2][]{\begin{tikzpicture}
    \tikzset{ribbon/.cd,#1}
    \pic{ribbon={#2}};
    \end{tikzpicture}}


\begin{document} 
    \pagecolor{white} 
    \BgThispage


\begin{center}
\TikZRibbon[node/.append style={font=\Huge,inner xsep=5em,
inner ysep=0.5em,fill=white},
outer/.append style={fill=white},
back/.append style={fill=white},inset=2cm,outset=5cm]{%
This ribbon is white as it should be.}
\end{center} 

\end{document} 

enter image description here

Please note that I do not have the Tigerramki file, so I used generic background graphics. Also, your code leads to a warning Package xcolor Warning: Incompatible color definition on input line 77., which is due to sciposter being very ancient and loading color instead of xcolor. Thie warning is not directly related to the scope of this answer, yet I fixed it by adding \RequirePackage{xcolor} at the very top. I also commented out packages that are not needed for the MWE (but of course they can be used).

  • Thank you for your answer, it works now. One question though. I actually included the fill option in my original post as well as the outer./style and other minor modifications compared your original answer under the other question. Why didn't that work? – Taufi Nov 24 '19 at 14:29
  • 1
    @Taufi The ... of \tikzset{pics/ribbon/.style={code={...}} is different in the upper and lower codes of my previous answer. It is perhaps my bad that I called both pics "ribbon". One could call them differently, e.g. "basic ribbon" and "fancier ribbon". The second version has several additions compared to the first one, but can still made fancier, and if one uses a different name for each of those, one may eventually run out of names. –  Nov 24 '19 at 14:34
  • Thank you for the clarification. – Taufi Nov 24 '19 at 15:03