Compilateur LaTeX en ligne
www.cpierquet.fr
fichiers/test/halignnb.tex
↓ télécharger
%!TEX pdflatex

\documentclass[french,a4paper,11pt,twocolumn]{article}
\usepackage[margin=2cm,includeheadfoot]{geometry}
\usepackage{calc,pgf,xintexpr}
\usepackage{xcolor}
\usepackage[sfdefault]{cabin}
\usepackage{babel}
\setlength\parindent{0pt}

%====halign numbers
\newlength\tmpwideststring
\newlength\tmpwideststringelt

\NewDocumentCommand\getwideststring{ m }{%
	\setlength\tmpwideststring{0pt}%
	\xintFor* ##1 in {\xintCSVtoList{#1}}\do{%
		\settowidth{\tmpwideststringelt}{##1}%
		\pgfmathsetlength{\global\tmpwideststring}{max(\tmpwideststring,\tmpwideststringelt)}%
	}%
}

\NewDocumentCommand\halignnb{ O{0,1,2,3,4,5,6,7,8,9} m }{%
	%#1 = ref strings
	%#2 = string
	\getwideststring{#1}%
	\makebox[\tmpwideststring][c]{#2}%
}

\begin{document}

\section{Normal}

{\LARGE\textcolor{blue!50!black}{Exercice 1 (3 points)}}

{\LARGE\textcolor{blue!50!black}{Exercice 2 (4 points)}}

{\LARGE\textcolor{blue!50!black}{Exercice 3 (5 points)}}

{\LARGE\textcolor{blue!50!black}{Exercice 4 (2 points)}}

\vfill\null

\pagebreak

\section{Patch halign}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{1} (\halignnb[3,4,5,2]{3} points)}}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{2} (\halignnb[3,4,5,2]{4} points)}}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{3} (\halignnb[3,4,5,2]{5} points)}}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{4} (\halignnb[3,4,5,2]{2} points)}}

\newpage

\section{Normal}

{\LARGE\textcolor{blue!50!black}{Exercice 1 (12 points)}}

{\LARGE\textcolor{blue!50!black}{Exercice 2 (8 points)}}

{\LARGE\textcolor{blue!50!black}{Exercice 3 (20 points)}}

{\LARGE\textcolor{blue!50!black}{Exercice 4 (15 points)}}

\vfill\null

\pagebreak

\section{Patch halign}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{1} (\halignnb[12,08,20,15]{12} points)}}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{2} (\halignnb[12,08,20,15]{08} points)}}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{3} (\halignnb[12,08,20,15]{20} points)}}

{\LARGE\textcolor{blue!50!black}{Exercice \halignnb[1,2,3,4]{4} (\halignnb[12,08,20,15]{15} points)}}

\end{document}