Skip to content

Instantly share code, notes, and snippets.

@flpinheiro
Created October 23, 2020 20:09
Show Gist options
  • Save flpinheiro/38d1a9aeeac73212c36042a8a0f162e3 to your computer and use it in GitHub Desktop.
Save flpinheiro/38d1a9aeeac73212c36042a8a0f162e3 to your computer and use it in GitHub Desktop.
Radio Button example to be used into tex file.
\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand*{\radiobutton}{%
\@ifstar{\@radiobutton0}{\@radiobutton1}%
}
\newcommand*{\@radiobutton}[1]{%
\begin{tikzpicture}
\pgfmathsetlengthmacro\radius{height("X")/2}
\draw[radius=\radius] circle;
\ifcase#1 \fill[radius=.6*\radius] circle;\fi
\end{tikzpicture}%
}
\makeatother
\newcommand{\radiolist}{
\begin{tabular}{ccccccccccc}
0 & 1& 2& 3& 4& 5& 6& 7& 8& 9& 10\\
\radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton& \radiobutton*\\
\end{tabular}
}
\begin{document}
\begin{itemize}
\item[\radiobutton] foo
\item[\radiobutton*] bar
\item[\radiobutton] baz
\end{itemize}
\radiolist
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment