mirror of
https://gitlab.com/netravnen/NetworkLabNotes.git
synced 2024-10-30 17:59:38 +00:00
Structure: Add macro baseconvertpractice
This commit is contained in:
parent
f3656191b1
commit
208ec230e7
|
@ -277,3 +277,34 @@
|
|||
% https://tex.stackexchange.com/a/146312
|
||||
\newlist{mylist}{enumerate*}{1}
|
||||
\setlist[mylist]{label={\alph*)},font={\color{red!25!black}\bfseries}}
|
||||
|
||||
|
||||
% https://cscrunch.com/blog/corey-pennycuff/scripting-latex-create-base-conversion-worksheet
|
||||
\def\colwidth{.42cm}
|
||||
\newcommand{\baseconvertpractice}[2]{% number, # to not censor (1-3, or 0 for none)
|
||||
\renewcommand\arraystretch{2}
|
||||
\FPeval{\num}{#1}%
|
||||
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}r|*{8}{>{\centering}p{\colwidth}|}|*{8}{>{\centering}p{\colwidth}|}@{}c@{}} \cline{2-17}%
|
||||
Decimal & \multicolumn{16}{ r| }{\censorifnotequal{\num}{#2}{1}} &\\ \cline{2-17}%
|
||||
Binary & \censorifnotequal{\getdigit{\num}{16}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{15}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{14}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{13}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{12}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{11}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{10}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{9}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{8}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{7}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{6}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{5}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{4}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{3}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{2}{2}}{#2}{2} &%
|
||||
\censorifnotequal{\getdigit{\num}{1}{2}}{#2}{2} &\\ \cline{2-17}%
|
||||
Hexadecimal & \multicolumn{4}{c|}{\censorifnotequal{\getdigit{\num}{4}{16}}{#2}{3}} &%
|
||||
\multicolumn{4}{c||}{\censorifnotequal{\getdigit{\num}{3}{16}}{#2}{3}} &%
|
||||
\multicolumn{4}{c|}{\censorifnotequal{\getdigit{\num}{2}{16}}{#2}{3}} &%
|
||||
\multicolumn{4}{c|}{\censorifnotequal{\getdigit{\num}{1}{16}}{#2}{3}} &\\ \cline{2-17}%
|
||||
\end{tabular*}%
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue