| 1 |
% !TeX TXS-program:compile = txs:///arara |
| 2 |
% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode} |
| 3 |
% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode} |
| 4 |
|
| 5 |
\documentclass[11pt,a4paper]{ltxdoc} |
| 6 |
%\usepackage{kpfonts} |
| 7 |
%\usepackage{bera} |
| 8 |
%\usepackage{inconsolata} |
| 9 |
\usepackage[T1]{fontenc} |
| 10 |
\usepackage[utf8]{inputenc} |
| 11 |
%\usepackage[scale=0.875]{cabin} |
| 12 |
\usepackage{timeop} |
| 13 |
\usepackage{fancyvrb} |
| 14 |
\usepackage{fancyhdr} |
| 15 |
\usepackage{fontawesome5} |
| 16 |
\fancyhf{} |
| 17 |
\renewcommand{\headrulewidth}{0pt} |
| 18 |
\lfoot{\sffamily\small [timeop]} |
| 19 |
\cfoot{\sffamily\small - \thepage{} -} |
| 20 |
\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}} |
| 21 |
\usepackage{hologo} |
| 22 |
\providecommand\tikzlogo{Ti\textit{k}Z} |
| 23 |
\providecommand\TeXLive{\TeX{}Live\xspace} |
| 24 |
\let\TikZ\tikzlogo |
| 25 |
|
| 26 |
\usepackage{hyperref} |
| 27 |
\urlstyle{same} |
| 28 |
\hypersetup{pdfborder=0 0 0} |
| 29 |
\usepackage[margin=2cm]{geometry} |
| 30 |
\setlength{\parindent}{0pt} |
| 31 |
\def\TPversion{0.1.1} |
| 32 |
\def\TPdate{05/05/2025} |
| 33 |
\usepackage{enumitem} |
| 34 |
\tcbuselibrary{hooks,listingsutf8,breakable} |
| 35 |
|
| 36 |
\lstdefinestyle{packagestyle} |
| 37 |
{ |
| 38 |
language=[LaTeX]TeX,% |
| 39 |
columns=fullflexible,% |
| 40 |
extendedchars=true,% |
| 41 |
basicstyle=\small\ttfamily,% |
| 42 |
keywordstyle={\color{black}},% |
| 43 |
classoffset=0,% |
| 44 |
keywords={},% |
| 45 |
alsoletter={-},% |
| 46 |
keywordstyle={\color{blue}},% |
| 47 |
classoffset=1,% |
| 48 |
alsoletter={-},% |
| 49 |
morekeywords={},% |
| 50 |
keywordstyle={\color{violet}},% |
| 51 |
classoffset=2,% |
| 52 |
alsoletter={-},% |
| 53 |
morekeywords={\hmstos,\hmtos,\stohms,\simpletimeop,\calctimeop,\boxhms},% |
| 54 |
keywordstyle={\color{green!50!black}},% |
| 55 |
classoffset=3,% |
| 56 |
morekeywords={zeros,raw,sys,noamsmath,find,type,colsep,sys},% |
| 57 |
keywordstyle={\color{orange}},% |
| 58 |
inputencoding=utf8/latin1 |
| 59 |
} |
| 60 |
|
| 61 |
\lstset{ |
| 62 |
% language=[LaTeX]TeX,% |
| 63 |
basicstyle=\small\ttfamily,% |
| 64 |
keywordstyle={},% |
| 65 |
% classoffset=0,% |
| 66 |
% keywords={},% |
| 67 |
% alsoletter={-},% |
| 68 |
% keywordstyle={\color{blue}},% |
| 69 |
% classoffset=1,% |
| 70 |
% alsoletter={-},% |
| 71 |
% morekeywords={},% |
| 72 |
% keywordstyle={\color{violet}},% |
| 73 |
% classoffset=2,% |
| 74 |
% alsoletter={-},% |
| 75 |
% morekeywords={calculatoritems,\CalcItemMenu,nwkstri,tidots,casiodots},% |
| 76 |
% keywordstyle={\color{green!50!black}},% |
| 77 |
% classoffset=3,% |
| 78 |
% morekeywords={xelua,noamssymb,model,type,fsep,font,len,bg,rightsymb},% |
| 79 |
% keywordstyle={\color{orange}} |
| 80 |
} |
| 81 |
|
| 82 |
\newtcblisting{DemoCode}[1]{% |
| 83 |
enhanced,width=\linewidth,% |
| 84 |
bicolor,size=title,% |
| 85 |
colback=cyan!10!white,% |
| 86 |
colbacklower=cyan!5!white,% |
| 87 |
colframe=cyan!75!black,% |
| 88 |
listing options={% |
| 89 |
columns=fullflexible,% |
| 90 |
breaklines=true,% |
| 91 |
breakatwhitespace=true,% |
| 92 |
style=packagestyle,% |
| 93 |
basicstyle=\footnotesize\ttfamily,% |
| 94 |
tabsize=4,% |
| 95 |
commentstyle={\itshape\color{gray}}, |
| 96 |
keywordstyle={\color{blue}},% |
| 97 |
classoffset=0,% |
| 98 |
keywords={\newfontfamily},% |
| 99 |
alsoletter={-},% |
| 100 |
keywordstyle={\color{blue}},% |
| 101 |
classoffset=1,% |
| 102 |
alsoletter={-},% |
| 103 |
morekeywords={timeop},% |
| 104 |
keywordstyle={\color{violet}},% |
| 105 |
classoffset=2,% |
| 106 |
alsoletter={-},% |
| 107 |
morekeywords={\hmstos,\hmtos,\stohms,\simpletimeop,\calctimeop,\boxhms},% |
| 108 |
keywordstyle={\color{green!50!black}},% |
| 109 |
classoffset=3,% |
| 110 |
morekeywords={zeros,raw,sys,noamsmath,find,type,colsep,sys},% |
| 111 |
keywordstyle={\color{orange}} |
| 112 |
},% |
| 113 |
#1 |
| 114 |
} |
| 115 |
|
| 116 |
\newtcbinputlisting\DemoCodeFile[1]{% |
| 117 |
enhanced,width=\linewidth,% |
| 118 |
bicolor,size=title,% |
| 119 |
colback=lightgray!10!white,% |
| 120 |
colbacklower=lightgray!5!white,% |
| 121 |
colframe=lightgray!75!black,% |
| 122 |
listing options={% |
| 123 |
breaklines=true,% |
| 124 |
breakatwhitespace=true,% |
| 125 |
style=tcblatex, |
| 126 |
extendedchars=true,% |
| 127 |
basicstyle=\tiny\ttfamily,% |
| 128 |
keywordstyle={},% |
| 129 |
tabsize=2,% |
| 130 |
commentstyle={\itshape\color{gray}},% |
| 131 |
inputencoding=utf8/latin1 |
| 132 |
},% |
| 133 |
breakable, |
| 134 |
listing only,% |
| 135 |
listing file={#1} |
| 136 |
} |
| 137 |
|
| 138 |
\NewDocumentCommand\ShowCode{ m }{% |
| 139 |
\colorbox{lightgray!50}{\lstinline!#1!}% |
| 140 |
} |
| 141 |
|
| 142 |
\begin{document} |
| 143 |
|
| 144 |
\thispagestyle{empty} |
| 145 |
|
| 146 |
\begin{center} |
| 147 |
\begin{minipage}{0.88\linewidth} |
| 148 |
\begin{tcolorbox}[colframe=yellow,colback=yellow!15] |
| 149 |
\begin{center} |
| 150 |
\renewcommand{\arraystretch}{1.25}% |
| 151 |
\begin{tabular}{c} |
| 152 |
{\Huge \texttt{timeop}}\\ |
| 153 |
\\ |
| 154 |
{\LARGE Calculates and displays arithmetic} \\ |
| 155 |
{\LARGE operations with durations.} \\ |
| 156 |
\\ |
| 157 |
{\small \texttt{Version \TPversion{} -- \TPdate}} |
| 158 |
\end{tabular} |
| 159 |
\end{center} |
| 160 |
\end{tcolorbox} |
| 161 |
\end{minipage} |
| 162 |
\end{center} |
| 163 |
|
| 164 |
\begin{center} |
| 165 |
\begin{tabular}{c} |
| 166 |
\texttt{Cédric Pierquet}\\ |
| 167 |
{\ttfamily c pierquet -- at -- outlook . fr}\\ |
| 168 |
\texttt{\url{https://forge.apps.education.fr/pierquetcedric/packages-latex}} \\ |
| 169 |
\end{tabular} |
| 170 |
\end{center} |
| 171 |
|
| 172 |
\hrule |
| 173 |
|
| 174 |
\vfill |
| 175 |
|
| 176 |
\begin{tcblisting}{colframe=lightgray,colback=lightgray!5} |
| 177 |
\simpletimeop{9,45,54}{4,28,57}{14,14,51} |
| 178 |
\end{tcblisting} |
| 179 |
|
| 180 |
\begin{tcblisting}{colframe=lightgray,colback=lightgray!5} |
| 181 |
\calctimeop% |
| 182 |
[type=-]% |
| 183 |
{9,45,54}% |
| 184 |
{9,28,57} |
| 185 |
\end{tcblisting} |
| 186 |
|
| 187 |
\begin{tcblisting}{colframe=lightgray,colback=lightgray!5} |
| 188 |
\calctimeop% |
| 189 |
[find={-,-,-,-,-,-,blue,yellow,red}]% |
| 190 |
{9,45,54}% |
| 191 |
{4,28,57} |
| 192 |
\end{tcblisting} |
| 193 |
|
| 194 |
\vfill~ |
| 195 |
|
| 196 |
%\hrule |
| 197 |
% |
| 198 |
%\medskip |
| 199 |
|
| 200 |
%\emph{% |
| 201 |
% The \textsf{luarandom} package do the same things, but with the obligation to compile with \hologo{LuaLaTeX}. |
| 202 |
%} |
| 203 |
% |
| 204 |
%\medskip |
| 205 |
|
| 206 |
\hrule |
| 207 |
|
| 208 |
\vspace*{5mm} |
| 209 |
|
| 210 |
\pagebreak |
| 211 |
|
| 212 |
\phantomsection |
| 213 |
|
| 214 |
\hypertarget{matoc}{} |
| 215 |
|
| 216 |
\tableofcontents |
| 217 |
|
| 218 |
\vspace*{5mm} |
| 219 |
|
| 220 |
\vfill |
| 221 |
|
| 222 |
\section{History \& Future} |
| 223 |
|
| 224 |
\texttt{0.1.1: Bugfix} |
| 225 |
|
| 226 |
\texttt{0.1.0: Initial version} |
| 227 |
|
| 228 |
\vspace*{5mm} |
| 229 |
|
| 230 |
%\hrule |
| 231 |
|
| 232 |
\pagebreak |
| 233 |
|
| 234 |
\section{Introduction} |
| 235 |
|
| 236 |
\subsection{Loading, useful packages} |
| 237 |
|
| 238 |
In order to load \ShowCode{timeop}, simply use: |
| 239 |
|
| 240 |
\begin{DemoCode}{listing only} |
| 241 |
\usepackage{timeop} |
| 242 |
\end{DemoCode} |
| 243 |
|
| 244 |
Loaded packages are \ShowCode{xstring}, \ShowCode{xintexpr}, \ShowCode{listofitems}, \ShowCode{tabularray}, \ShowCode{simplekv} and \ShowCode{tcolorbox}. |
| 245 |
|
| 246 |
Loaded libraries are \ShowCode{skins}. |
| 247 |
|
| 248 |
\smallskip |
| 249 |
|
| 250 |
If \ShowCode{amsmath} doen't need to be loaded (useful for int. macro), just add \ShowCode{[noamssymb]} to the loading. |
| 251 |
|
| 252 |
\begin{DemoCode}{listing only} |
| 253 |
%w/o amsmath loading |
| 254 |
\usepackage[noamsmath]{timeop} |
| 255 |
\end{DemoCode} |
| 256 |
|
| 257 |
\subsection{Special macro} |
| 258 |
|
| 259 |
Special macros are available, to mark a \textit{finding number}, which is adapted to current font. |
| 260 |
|
| 261 |
\begin{DemoCode}{} |
| 262 |
\boxhms{red} / \boxhms{yellow} / \boxhms{orange} / \boxhms{teal} |
| 263 |
\end{DemoCode} |
| 264 |
|
| 265 |
\section{Usage} |
| 266 |
|
| 267 |
\subsection{Conversion s--hms or hm(s)--s} |
| 268 |
|
| 269 |
First available macros can convert times within hms and s. |
| 270 |
|
| 271 |
\begin{DemoCode}{listing only} |
| 272 |
%convert hm to s |
| 273 |
\hmtos{h,m}[\macro] |
| 274 |
%convert hms to s |
| 275 |
\hmstos{h,min,s}[\macro] |
| 276 |
%convert and/or print s to hms |
| 277 |
\stohms[keys]{s}[\macro] |
| 278 |
\end{DemoCode} |
| 279 |
|
| 280 |
Available keys are: |
| 281 |
|
| 282 |
\begin{itemize}[leftmargin=*] |
| 283 |
\item \ShowCode{sys} : version of formatting system (\texttt{eu} by default); |
| 284 |
\item \ShowCode{zeros} : boolean for leading zeros (\texttt{true} by default); |
| 285 |
\item \ShowCode{raw} : boolean for storing raw result into \ShowCode{[\\macro]} (\texttt{true} by default). |
| 286 |
\end{itemize} |
| 287 |
|
| 288 |
If \ShowCode{[raw=false]}, the code format the result within \ShowCode{hh h mm min ss s} main format (zero value are not printed). |
| 289 |
|
| 290 |
\begin{DemoCode}{} |
| 291 |
\hmtos{1,45}\convtosec\\ |
| 292 |
\hmstos{9,45,54}\convtosec\\ |
| 293 |
\stohms{35154}\convtohms |
| 294 |
\end{DemoCode} |
| 295 |
|
| 296 |
\begin{DemoCode}{} |
| 297 |
\stohms[raw=false]{1000}\\ |
| 298 |
\stohms[raw=false]{36000}\\ |
| 299 |
\stohms[raw=false,zeros=false]{36120}\\ |
| 300 |
\stohms[raw=false]{36010}\\ |
| 301 |
\stohms[raw=false]{3599}\\ |
| 302 |
\stohms[raw=false,sys=en]{3599} |
| 303 |
\end{DemoCode} |
| 304 |
|
| 305 |
\subsection{Addition, subtraction} |
| 306 |
|
| 307 |
The purpose of the second macro is to present addition or subtraction of duration, within \textit{hms} format. |
| 308 |
|
| 309 |
Two methods are given: |
| 310 |
|
| 311 |
\begin{itemize} |
| 312 |
\item the \textit{simple} way, with result given; |
| 313 |
\item the \textit{compute} way, with result calculated. |
| 314 |
\end{itemize} |
| 315 |
|
| 316 |
\begin{DemoCode}{listing only} |
| 317 |
%simple way |
| 318 |
\simpletimeop[keys]{h1,m1,s1}{h2,m2,s2}{h3,m3,s3} |
| 319 |
|
| 320 |
%compute way |
| 321 |
\calctimeop[keys]{h1,m1,s1}{h2,m2,s2} |
| 322 |
\end{DemoCode} |
| 323 |
|
| 324 |
Available keys are: |
| 325 |
|
| 326 |
\begin{itemize}[leftmargin=*] |
| 327 |
\item \ShowCode{zeros} : boolean for leading zeros (\texttt{false} by default); |
| 328 |
\item \ShowCode{type} : \texttt{+} for addition, \texttt{-} for subtraction \ShowCode{+} (\texttt{true} by default); |
| 329 |
\item \ShowCode{colsep} : length of \texttt{colsep} for columns (\texttt{1.5pt} by default); |
| 330 |
\item \ShowCode{find} : list of \texttt{colors} for 'finding boxes' (\texttt{empty} by default). |
| 331 |
\end{itemize} |
| 332 |
|
| 333 |
So: |
| 334 |
|
| 335 |
\begin{itemize} |
| 336 |
\item for the \textit{simple way}, arguments can be given with \ShowCode{\\boxhms} or integer values ; |
| 337 |
\item for the \textit{compute way}, the code adapt result for hms or hm format, and \ShowCode{find} can be given with \texttt{-} fir ignoring finding items. |
| 338 |
\end{itemize} |
| 339 |
|
| 340 |
\begin{DemoCode}{} |
| 341 |
\simpletimeop{9,45,54}{4,28,57}{14,14,51} |
| 342 |
\end{DemoCode} |
| 343 |
|
| 344 |
\begin{DemoCode}{} |
| 345 |
\simpletimeop{9,45,54}{4,28,57}{\boxhms{red},\boxhms{blue},\boxhms{purple}} |
| 346 |
\end{DemoCode} |
| 347 |
|
| 348 |
\begin{DemoCode}{} |
| 349 |
\simpletimeop[type=-]{9,45}{4,28}{\boxhms{red},\boxhms{blue}} |
| 350 |
\end{DemoCode} |
| 351 |
|
| 352 |
\begin{DemoCode}{} |
| 353 |
\calctimeop% |
| 354 |
[type=-]% |
| 355 |
{9,45,54}% |
| 356 |
{9,28,57} |
| 357 |
\end{DemoCode} |
| 358 |
|
| 359 |
\begin{DemoCode}{} |
| 360 |
\calctimeop% |
| 361 |
[find={blue,-,-,-,green,-,-,-,orange}]% |
| 362 |
{9,45,54}% |
| 363 |
{4,28,57} |
| 364 |
\end{DemoCode} |
| 365 |
|
| 366 |
\begin{DemoCode}{} |
| 367 |
{\LARGE\ttfamily\calctimeop[find={-,-,-,-,orange,teal},type=-,colsep=3pt]{9,45}{4,28}} |
| 368 |
\end{DemoCode} |
| 369 |
|
| 370 |
\pagebreak |
| 371 |
|
| 372 |
\section{The code} |
| 373 |
|
| 374 |
\DemoCodeFile{timeop.sty} |
| 375 |
|
| 376 |
\end{document} |