% !TeX TXS-program:compile = txs:///arara
% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode}
% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode}

\documentclass[11pt,a4paper]{ltxdoc}
\usepackage{bera}
\usepackage{inconsolata}
\usepackage[T1]{fontenc}
\usepackage[scale=0.875]{cabin}
\usepackage{randintlist-l3}
\usepackage{listofitems,xintexpr}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{tabularray}
\usepackage{fontawesome5}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\lfoot{\sffamily\small [randintlist-l3]}
\cfoot{\sffamily\small - \thepage{} -}
\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}}
\usepackage{hologo}
\providecommand\tikzlogo{Ti\textit{k}Z}
\providecommand\TeXLive{\TeX{}Live\xspace}
\let\TikZ\tikzlogo

\usepackage{hyperref}
\urlstyle{same}
\hypersetup{pdfborder=0 0 0}
\usepackage[margin=2cm]{geometry}
\setlength{\parindent}{0pt}
\def\TPversion{0.20a}
\def\TPdate{20/02/2026}
\usepackage{tcolorbox}
\usepackage{pgffor}
\tcbuselibrary{breakable,skins,hooks,listingsutf8}
%\usepackage{soul}
%\sethlcolor{lightgray!25}

\lstset{
	language=[LaTeX]TeX,%
	basicstyle=\ttfamily,%
	keywordstyle={\color{blue}},%
	classoffset=0,%
	keywords={},%
	alsoletter={-},%
	keywordstyle={\color{blue}},%
	classoffset=1,%
	alsoletter={-},%
	morekeywords={randintlist-l3},%
	keywordstyle={\color{violet}},%
	classoffset=2,%
	alsoletter={-},%
	morekeywords={\rdlgenlist,\rdlgetitem},%
	keywordstyle={\color{green!50!black}},%
	classoffset=3,%
	morekeywords={min,max,nb,seed,sort,sep,repeat,excluded},%
	keywordstyle={\color{orange}}
}

\newtcblisting{DemoCode}[1]{%
	enhanced,width=\linewidth,%
	bicolor,size=title,%
	colback=cyan!10!white,%
	colbacklower=cyan!5!white,%
	colframe=cyan!75!black,%
	listing options={%
		breaklines=true,%
		breakatwhitespace=true,%
		style=tcblatex,basicstyle=\small\ttfamily,%
		tabsize=4,%
		commentstyle={\itshape\color{gray}},
		keywordstyle={\color{blue}},%
		classoffset=0,%
		keywords={\usepackage,\includegraphics,xstring,listofitems,tikz,calc,simplekv,graphicx,\readlist,\showitems,\xintFor,\xintSeq},%
		alsoletter={-},%
		keywordstyle={\color{blue}},%
		classoffset=1,%
		alsoletter={-},%
		morekeywords={randintlist-l3},%
		keywordstyle={\color{violet}},%
		classoffset=2,%
		alsoletter={-},%
		morekeywords={\rdlgenlist,\rdlgetitem},%
		keywordstyle={\color{green!50!black}},%
		classoffset=3,%
		morekeywords={min,max,nb,seed,sort,sep,repeat,excluded},%
		keywordstyle={\color{orange}}
	},%
	#1
}

\newtcbinputlisting\DemoCodeFile[1]{%
	enhanced,width=\linewidth,%
	bicolor,size=title,%
	colback=lightgray!10!white,%
	colbacklower=lightgray!5!white,%
	colframe=lightgray!75!black,%
	listing options={%
		breaklines=true,%
		breakatwhitespace=true,%
		style=tcblatex,
		basicstyle=\scriptsize\ttfamily,%
		tabsize=4,%
		commentstyle={\itshape\color{gray}},%
		lastline=246
	},%
	breakable,
	listing only,%
	listing file={#1}
}

\NewDocumentCommand\ShowCode{ m }{%
	\lstinline{#1}%
}

\begin{document}

\thispagestyle{empty}

\begin{center}
	\begin{minipage}{0.88\linewidth}
		\begin{tcolorbox}[colframe=yellow,colback=yellow!15]
			\begin{center}
				\renewcommand{\arraystretch}{1.25}%
				\begin{tabular}{c}
					{\Huge \texttt{randintlist-l3}}\\
					\\
					{\Large\hologo{LaTeX3}}\\
					\\
					{\LARGE Creating random integer number lists,} \\
					{\LARGE with multiple numbers or not,} \\
					{\LARGE sorted or not.} \\
					\\
					{\small \texttt{Version \TPversion{} -- \TPdate}}
				\end{tabular}
			\end{center}
		\end{tcolorbox}
	\end{minipage}
\end{center}

\begin{center}
	\begin{tabular}{c}
		\texttt{Cédric Pierquet}\\
		{\ttfamily c pierquet -- at -- outlook . fr}\\
		\texttt{\url{https://github.com/cpierquet/latex-packages/tree/main/randintlist}} \\
	\end{tabular}
\end{center}

\hrule

\vfill

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
10 numbers, between 1 and 100, without repetition:

\hfill\rdlgenlist[min=1,max=100,nb=10,repeat=false]{\mylist}\textcolor{red}{\mylist}\hfill~

The 5th value is:

\hfill\textcolor{blue}{\rdlgetitem*{\mylist}{5}}\hfill~
\end{tcolorbox}

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
10 numbers, between 1 and 100, without multiples of 5:

\hfill\rdlgenlist[min=1,max=100,nb=10,excluded={5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100}]{\mylist}\textcolor{olive}{\mylist}\hfill~

The 9th value is:

\hfill\textcolor{purple}{\rdlgetitem*{\mylist}{9}}\hfill~
\end{tcolorbox}

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
15 numbers, between 1 and 20, with repetition:

\hfill\rdlgenlist[min=1,max=20,nb=15,repeat]{\mylist}\textcolor{red}{\mylist}\hfill~

The last value is:

\hfill\textcolor{blue}{\rdlgetitem*{\mylist}{-1}}\hfill~
\end{tcolorbox}

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
6 sorted numbers, between 1 and 51, without repetition:

\hfill\rdlgenlist[min=1,max=51,nb=6,sort=asc,repeat=false]{\mylist}ascending: \textcolor{red}{\mylist}\hfill~

\hfill\rdlgenlist[min=1,max=51,nb=6,sort=des,repeat=false]< {>} >{\mylist}descending: \textcolor{red}{\mylist}\hfill~
\end{tcolorbox}

\vfill~

\hrule

\medskip

\emph{%
	1. The \textsf{luarandom} package do the same things, but with the obligation to compile with \hologo{LuaLaTeX}.
}

\emph{%
	2. The \textsf{tuple} package is so much better\ldots take a look\ldots
}

\medskip

\hrule

\vspace*{5mm}

\pagebreak

\phantomsection

\hypertarget{matoc}{}

\tableofcontents

\vspace*{5mm}

%\hrule

\pagebreak

\section{Loading, useful packages}

In order to load \texttt{randintlist-l3}, simply use:

\begin{DemoCode}{listing only}
\usepackage{randintlist-l3}
\end{DemoCode}

All code is written in \hologo{LaTeX3}, so no extra packages are needed.

\section{The Macros}

\subsection{Global usage}

Package \texttt{randintlist-l3} supports the creation of random integer number lists where a number will appear only once or multiple times. Generated lists can be used with \texttt{listofitems}.

\medskip

{\small\faLightbulb} Macros are prefixed with \ShowCode{\\rdl...} (for \textsf{\textbf{\underline{r}}an\textbf{\underline{d}}int\textbf{\underline{l}}ist}).

\subsection{Generate the list}

\begin{DemoCode}{listing only}
%generate list
\rdlgenlist[keys]{\macro}
\end{DemoCode}

Available keys are:

\begin{itemize}
	\item \ShowCode{min}: minimum value (default \ShowCode{1});
	\item \ShowCode{max}: maximum value (default \ShowCode{100});
	\item \ShowCode{nb}: number of values (default \ShowCode{10});
	\item \ShowCode{sort}: sorting options, within \ShowCode{no/asc/dec} (default \ShowCode{no});
	\item \ShowCode{repeat}: boolean to authorize repeating values (default \ShowCode{true});
	\item \ShowCode{excluded}: list of excluded values (default \ShowCode{empty});
	\item \ShowCode{seed}: random seed value according to used packages (default \ShowCode{-1}).
\end{itemize}

\begin{DemoCode}{}
%default values
\rdlgenlist{\mylistA}\mylistA
\end{DemoCode}

\begin{DemoCode}{}
%10 between 1 and 50, with ascending
\rdlgenlist[sort=asc,min=1,max=50,nb=10,repeat=false]{\mylistB}\mylistB
\end{DemoCode}

\begin{DemoCode}{}
%15 between 1 and 50, with ascending and repetitions allowed
\rdlgenlist[sort=asc,min=1,max=50,nb=15]{\mylistC}\mylistC
\end{DemoCode}

\begin{DemoCode}{}
%15 between 1 and 50, without multiples of 5
\rdlgenlist[%
	sort=asc,min=1,max=50,nb=15,%
	excluded={5,10,15,20,25,30,35,40,45,50}]%
	{\mylistC}\mylistC
\end{DemoCode}

\begin{DemoCode}{}
%list used with listofitems
\rdlgenlist{\mylistD}\mylistD\par
\readlist*\mylistused{\mylistD}\showitems{\mylistused}\par
\mylistused[1]; \mylistused[-1]
\end{DemoCode}

\begin{DemoCode}{}
%list, with alt sep, used with listofitems
\rdlgenlist<+>{\mylistZ}\mylistZ\par
\setsepchar{+}\readlist*\mylistused{\mylistZ}\showitems{\mylistused}\par
\mylistused[1]; \mylistused[-1]
\end{DemoCode}

\subsection{Accessing elements}

\begin{DemoCode}{listing only}
%accessing item
\rdlgetitem(*){\macro}{index}[\macrores]
\end{DemoCode}

\begin{DemoCode}{}
%with default keys
\rdlgenlist{\mylistE}raw list: \mylistE\par
items list:\par
\xintFor* #1 in {\xintSeq{1}{6}}\do{\rdlgetitem*{\mylistE}{#1}\par}
first element: \rdlgetitem*{\mylistE}{1}\par
\end{DemoCode}

\begin{DemoCode}{}
\rdlgetitem{\mylistE}{3}[\myres]%
third element: \myres
\end{DemoCode}

\pagebreak

\section{History}

\texttt{0.20a: Improvements with \hologo{LaTeX3}}

\texttt{0.1.6: Improvements with \hologo{LaTeX3}}

\texttt{0.1.5: Initial version}

\section{The code}

\DemoCodeFile{randintlist-l3.sty}

\end{document}
