3

I want to produce the same result as this commands related to the beamer-class in a document using the article-class :

\hyperlink{question}{\beamergotobutton{Allez à la question}}
\hyperlink{partie}{\beamerskipbutton{Sautez cette partie}}
\hyperlink{label}{\beamerreturnbutton{Retour}}

This produces the following output :

Output example

Is there a way to have the same output in an article ?

For some context, I want to use this buttons to link pages and text segments across a document with hyperlinks that I can already produce with hyperref.

2 Answers 2

5

Just for fun. I pick "button" related definitions from beamer source files and replace \(def|use)beamertemplate staff by some direct macro uses.

Beamer hard-coded the size of the rounded rectangle (for example, try replace \tiny with \small in example below), so for a more flexible (but less efficient) solution, a tikz node with shape rounded rectangle is better.

\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}

% copied from beamercolorthemedefault.sty
% begin
\definecolor{beamer@blendedblue}{rgb}{0.2,0.2,0.7}
% end

\colorlet{button}{beamer@blendedblue}
\colorlet{button border}{beamer@blendedblue}

\makeatletter
\newbox\beamer@tempbox
\newdimen\beamer@tempdim

% copied from beamerinnerthemedefault.sty
% begin
\newdimen\beamer@dima
\newdimen\beamer@dimb

%\defbeamertemplate*{button}{default}
\def\beamer@@tmpl@button
{%
  \setbox\beamer@tempbox=\hbox{{\insertbuttontext}}%
  \ht\beamer@tempbox=6pt%
  \dp\beamer@tempbox=0pt%
  \setbox\beamer@tempbox=\vbox{\box\beamer@tempbox\vskip2pt}%
  \beamer@tempdim=\wd\beamer@tempbox%
  \beamer@dima=\beamer@tempdim\advance\beamer@dima by2.2pt
  \beamer@dimb=\beamer@tempdim\advance\beamer@dimb by4pt
  \begin{pgfpicture}{-4pt}{0pt}{\the\beamer@tempdim}{8pt}
%    \color{bg}
    \pgfsetfillcolor{button}
    \pgfsetlinewidth{0.8pt}
    \pgfpathqmoveto{0pt}{0pt}
    \pgfpathqcurveto{-2.2pt}{0pt}{-4pt}{1.8pt}{-4pt}{4pt}
    \pgfpathqcurveto{-4pt}{6.2pt}{-2.2pt}{8pt}{0pt}{8pt}
    \pgfpathlineto{\pgfpoint{\the\beamer@tempdim}{8pt}}
    \pgfpathcurveto%
    {\pgfpoint{\the\beamer@dima}{8pt}}%
    {\pgfpoint{\the\beamer@dimb}{6.2pt}}%
    {\pgfpoint{\the\beamer@dimb}{4pt}}
    \pgfpathcurveto%
    {\pgfpoint{\the\beamer@dimb}{1.8pt}}%
    {\pgfpoint{\the\beamer@dima}{0pt}}%
    {\pgfpoint{\the\beamer@tempdim}{0pt}}
    \pgfpathclose
    \pgfusepathqfill
%    \colorlet{bg}{parent.bg}
%    \usebeamercolor[fg]{button border}
    \pgfsetstrokecolor{button border}
    \pgfpathqmoveto{0pt}{0pt}
    \pgfpathqcurveto{-2.2pt}{0pt}{-4pt}{1.8pt}{-4pt}{4pt}
    \pgfpathqcurveto{-4pt}{6.2pt}{-2.2pt}{8pt}{0pt}{8pt}
    \pgfpathlineto{\pgfpoint{\the\beamer@tempdim}{8pt}}
    \pgfpathcurveto%
    {\pgfpoint{\the\beamer@dima}{8pt}}%
    {\pgfpoint{\the\beamer@dimb}{6.2pt}}%
    {\pgfpoint{\the\beamer@dimb}{4pt}}
    \pgfpathcurveto%
    {\pgfpoint{\the\beamer@dimb}{1.8pt}}%
    {\pgfpoint{\the\beamer@dima}{0pt}}%
    {\pgfpoint{\the\beamer@tempdim}{0pt}}
    \pgfpathclose
    \pgfusepathqstroke
  \end{pgfpicture}%
  \hskip-\beamer@tempdim%
  \box\beamer@tempbox%
  \kern4pt%
}
% end

% copied from beamerbasenavigation.sty
% begin
\pgfdefobject{beamergotosymbol}{\pgfpoint{0pt}{-1pt}}{\pgfpoint{5pt}{5pt}}
{
  \pgfpathqmoveto{1.5bp}{0.5bp}
  \pgfpathqlineto{3.5bp}{2bp}
  \pgfpathqlineto{1.5bp}{3.5bp}
  \pgfusepathqfill
}

\def\insertgotosymbol{%
  \begin{pgfpicture}{1pt}{0pt}{6pt}{5pt}
    \pgfuseobject{beamergotosymbol}%
  \end{pgfpicture}}

\pgfdefobject{beamerskipsymbol}{\pgfpoint{0pt}{-1pt}}{\pgfpoint{7pt}{5pt}}
{
  \pgfpathqmoveto{1.5bp}{0.5bp}
  \pgfpathqlineto{3.5bp}{2bp}
  \pgfpathqlineto{1.5bp}{3.5bp}
  \pgfpathqmoveto{3.5bp}{0.5bp}
  \pgfpathqlineto{5.5bp}{2bp}
  \pgfpathqlineto{3.5bp}{3.5bp}
  \pgfusepathqfill
}

\def\insertskipsymbol{%
  \begin{pgfpicture}{1pt}{0pt}{8pt}{5pt}
    \pgfuseobject{beamerskipsymbol}%
  \end{pgfpicture}}


\pgfdefobject{beamerreturnsymbol}{\pgfpoint{0pt}{-1pt}}{\pgfpoint{5pt}{5pt}}
{
  \pgfpathqmoveto{3.5bp}{0.5bp}
  \pgfpathqlineto{1.5bp}{2bp}
  \pgfpathqlineto{3.5bp}{3.5bp}
  \pgfusepathqfill
}

\def\insertreturnsymbol{%
  \begin{pgfpicture}{1pt}{0pt}{6pt}{5pt}
    \pgfuseobject{beamerreturnsymbol}%
  \end{pgfpicture}}


%\def\beamerbutton#1{\def\insertbuttontext{#1}\usebeamertemplate**{button}}
\def\beamerbutton#1{%
  \def\insertbuttontext{#1}%
  {\sffamily\tiny\color{white}\beamer@@tmpl@button}}
\def\beamergotobutton#1{\beamerbutton{\insertgotosymbol#1}}
\def\beamerskipbutton#1{\beamerbutton{\insertskipsymbol#1}}
\def\beamerreturnbutton#1{\beamerbutton{\insertreturnsymbol#1}}
% end
\makeatother

\newcommand{\myhyperlink}[2]{%
  {\hypersetup{hidelinks}\hyperlink{#1}{#2}}}

\begin{document}
\myhyperlink{question}{\beamergotobutton{Allez à la question}}
\myhyperlink{partie}{\beamerskipbutton{Sautez cette partie}}
\myhyperlink{label}{\beamerreturnbutton{Retour}}
\end{document}

enter image description here

1
  • Thanks, that's exactly what I wanted.
    – Elyo
    Dec 29, 2021 at 13:55
4

You can achieve something simiar using a customized tcolorbox:

enter image description here

\documentclass{article}
\usepackage{amssymb}

\usepackage[most]{tcolorbox}

\definecolor{myblue}{RGB}{153,153,217}
\newtcbox{\inlinebox}[1][]{enhanced,
                           box align=base,
                           nobeforeafter,
                           colback=myblue,
                           size=small,
                           boxrule=0pt,
                           left=0pt, right=0pt,
                           boxsep=2pt,
                           arc=5pt,
                           fontupper=\color{white},
                           #1}

\newcommand{\mylinkbox}[1]{\inlinebox{$\blacktriangleright$  \nameref{#1}}}

\usepackage{nameref}
\usepackage[hidelinks]{hyperref}

\begin{document}
\section{first section}\label{sec:example}
\newpage
Some regular text and a link box: \mylinkbox{sec:example} more regular text
\end{document}
1
  • Thanks, I never thought of using tcolorbox here. But I prefer the solution of @muzimuzhi Z. Yours is easier to understand.
    – Elyo
    Dec 29, 2021 at 13:54

You must log in to answer this question.

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