| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: siunitx-sexagesimal.dtx Copyright (C) 2016-2019,2021-2026 Joseph Wright |
| 4 |
% |
| 5 |
% It may be distributed and/or modified under the conditions of the |
| 6 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 7 |
% license or (at your option) any later version. The latest version |
| 8 |
% of this license is in the file |
| 9 |
% |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% This file is part of the "siunitx bundle" (The Work in LPPL) |
| 13 |
% and all files in that bundle must be distributed together. |
| 14 |
% |
| 15 |
% The released version of this bundle is available from CTAN. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/josephwright/siunitx |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
% ----------------------------------------------------------------------- |
| 26 |
% |
| 27 |
%<*driver> |
| 28 |
\documentclass{l3doc} |
| 29 |
% Additional commands needed in this source |
| 30 |
\ProvideDocumentCommand\email{m}{\href{mailto:#1}{\nolinkurl{#1}}} |
| 31 |
\ProvideDocumentCommand\foreign{m}{\textit{#1}} |
| 32 |
% The next line is needed so that \GetFileInfo will be able to pick up |
| 33 |
% version data |
| 34 |
\usepackage{siunitx} |
| 35 |
\begin{document} |
| 36 |
\DocInput{\jobname.dtx} |
| 37 |
\end{document} |
| 38 |
%</driver> |
| 39 |
% \fi |
| 40 |
% |
| 41 |
% \GetFileInfo{siunitx.sty} |
| 42 |
% |
| 43 |
% \title{^^A |
| 44 |
% \pkg{siunitx-sexagesimal} -- Formatting sexagesimal values^^A |
| 45 |
% \thanks{This file describes \fileversion, |
| 46 |
% last revised \filedate.}^^A |
| 47 |
% } |
| 48 |
% |
| 49 |
% \author{^^A |
| 50 |
% Joseph Wright^^A |
| 51 |
% \thanks{^^A |
| 52 |
% E-mail: |
| 53 |
% \email{[email protected]}^^A |
| 54 |
% }^^A |
| 55 |
% } |
| 56 |
% |
| 57 |
% \date{Released \filedate} |
| 58 |
% |
| 59 |
% \maketitle |
| 60 |
% |
| 61 |
% \begin{documentation} |
| 62 |
% |
| 63 |
% \section{Formatting sexagesimal values} |
| 64 |
% |
| 65 |
% The generic sexagesimal formatting code is designed for values which have |
| 66 |
% three components, each related by a factor of 60 to the next higher |
| 67 |
% component. |
| 68 |
% |
| 69 |
% \begin{function} |
| 70 |
% { |
| 71 |
% \siunitx_sexagesimal:n, \siunitx_sexagesimal:e, |
| 72 |
% \siunitx_sexagesimal:nnn, \siunitx_sexagesimal:eee |
| 73 |
% } |
| 74 |
% \begin{syntax} |
| 75 |
% \cs{siunitx_sexagesimal:n} \Arg{decimal} |
| 76 |
% \cs{siunitx_sexagesimal:nnn} \Arg{major} \Arg{intermediate} \Arg{minor} |
| 77 |
% \end{syntax} |
| 78 |
% Typeset the \meta{sexagesimal} value (which may be given as separate |
| 79 |
% \meta{major}, \meta{intermediate} and \meta{minor} components). The |
| 80 |
% \meta{sexagesimal} (or components) may be given as expressions. The |
| 81 |
% \meta{sexagesimal} should be a number as understood by |
| 82 |
% \cs{siunitx_format_number:nN}, with no uncertainty, exponent or imaginary |
| 83 |
% part. The unit symbols for \meta{major}, \meta{intermediate}, \meta{minor} |
| 84 |
% are set by the options described below. |
| 85 |
% \end{function} |
| 86 |
% |
| 87 |
% \begin{function}{sexagesimal-mode} |
| 88 |
% \begin{syntax} |
| 89 |
% |sexagesimal-mode| = \meta{choice} |
| 90 |
% \end{syntax} |
| 91 |
% Selects how sexagesimal values are formatted: a choice from |
| 92 |
% the options |parts|, |decimal| and |input|. The option |components| means |
| 93 |
% that sexagesimal values will always be typeset in components (major, |
| 94 |
% intermediate, minor) format, whilst |decimal| means that angles are typeset |
| 95 |
% as a single decimal value. The |input| setting means that the input format |
| 96 |
% (\foreign{i.e.}~difference between \cs{siunitx_sexagesimal:n} and |
| 97 |
% \cs{siunitx_sexagesimal:nnn}) is maintained. The standard setting is |
| 98 |
% |input|. |
| 99 |
% \end{function} |
| 100 |
% |
| 101 |
% \begin{function} |
| 102 |
% { |
| 103 |
% fill-sexagesimal-major , |
| 104 |
% fill-sexagesimal-intermediate , |
| 105 |
% fill-sexagesimal-minor |
| 106 |
% } |
| 107 |
% \begin{syntax} |
| 108 |
% |fill-sexagesimal-major| = |true|\verb"|"|false| |
| 109 |
% \end{syntax} |
| 110 |
% Determines whether a missing component is zero-filled when printing an |
| 111 |
% arc. The standard setting is |false|. |
| 112 |
% \end{function} |
| 113 |
% |
| 114 |
% \begin{function}{sexagesimal-separator} |
| 115 |
% \begin{syntax} |
| 116 |
% |sexagesimal-separator| = \meta{separator} |
| 117 |
% \end{syntax} |
| 118 |
% Inserted between component parts (major, intermediate and minor |
| 119 |
% components). The standard setting is empty. |
| 120 |
% \end{function} |
| 121 |
% |
| 122 |
% \begin{function} |
| 123 |
% { |
| 124 |
% sexagesimal-unit-major , |
| 125 |
% sexagesimal-unit-intermediate , |
| 126 |
% sexagesimal-unit-minor |
| 127 |
% } |
| 128 |
% \begin{syntax} |
| 129 |
% |sexagesimal-unit-major| = \meta{unit} |
| 130 |
% \end{syntax} |
| 131 |
% Sets the unit symbol(s) used for major, intermediate and minor components, |
| 132 |
% respectively. The standard settings are empty. |
| 133 |
% \end{function} |
| 134 |
% |
| 135 |
% \begin{function}{sexagesimal-unit-over-decimal} |
| 136 |
% \begin{syntax} |
| 137 |
% |sexagesimal-unit-over-decimal| = |true|\verb"|"|false| |
| 138 |
% \end{syntax} |
| 139 |
% Determines if the component separator is printed over the decimal marker. |
| 140 |
% The standard setting is |false|. |
| 141 |
% \end{function} |
| 142 |
% |
| 143 |
% \section{Formatting angles} |
| 144 |
% |
| 145 |
% \begin{function} |
| 146 |
% { |
| 147 |
% \siunitx_angle:n, \siunitx_angle:e, |
| 148 |
% \siunitx_angle:nnn, \siunitx_angle:eee |
| 149 |
% } |
| 150 |
% \begin{syntax} |
| 151 |
% \cs{siunitx_angle:n} \Arg{angle} |
| 152 |
% \cs{siunitx_angle:nnn} \Arg{degrees} \Arg{minutes} \Arg{seconds} |
| 153 |
% \end{syntax} |
| 154 |
% Typeset the \meta{angle} (which may be given as separate \meta{degree}, |
| 155 |
% \meta{minute} and \meta{second} components). The \meta{angle} |
| 156 |
% (or components) may be given as expressions. The \meta{angle} should be a |
| 157 |
% number as understood by \cs{siunitx_format_number:nN}, with no uncertainty, |
| 158 |
% exponent or imaginary part. The unit symbols for degrees, minutes and |
| 159 |
% seconds are |\degree|, |\arcminute| and |\arcsecond|, respectively. |
| 160 |
% \end{function} |
| 161 |
% |
| 162 |
% \begin{function}{angle-mode} |
| 163 |
% \begin{syntax} |
| 164 |
% |angle-mode| = \meta{choice} |
| 165 |
% \end{syntax} |
| 166 |
% Selects how angles are formatted: a choice from |
| 167 |
% the options |arc|, |decimal| and |input|. The option |arc| means that angles |
| 168 |
% will always be typeset in arc (degree, minute, second) format, whilst |
| 169 |
% |decimal| means that angles are typeset as a single decimal value. The |
| 170 |
% |input| setting means that the input format (\foreign{i.e.}~difference |
| 171 |
% between \cs{siunitx_angle:n} and \cs{siunitx_angle:nnn}) is maintained. The |
| 172 |
% standard setting is |input|. |
| 173 |
% \end{function} |
| 174 |
% |
| 175 |
% \begin{function} |
| 176 |
% { |
| 177 |
% angle-symbol-degree , |
| 178 |
% angle-symbol-minute , |
| 179 |
% angle-symbol-second |
| 180 |
% } |
| 181 |
% \begin{syntax} |
| 182 |
% |angle-symbol-degree| = \meta{symbol} |
| 183 |
% \end{syntax} |
| 184 |
% Sets the symbol used for arc degrees, minutes or seconds, respectively. |
| 185 |
% \end{function} |
| 186 |
% |
| 187 |
% \begin{function}{angle-symbol-over-decimal} |
| 188 |
% \begin{syntax} |
| 189 |
% |angle-symbol-over-decimal| = |true|\verb"|"|false| |
| 190 |
% \end{syntax} |
| 191 |
% Determines if the arc separator is printed over the decimal marker, a |
| 192 |
% format used in astronomy. The standard setting is |false|. |
| 193 |
% \end{function} |
| 194 |
% |
| 195 |
% \begin{function}{angle-separator} |
| 196 |
% \begin{syntax} |
| 197 |
% |angle-separator| = \meta{separator} |
| 198 |
% \end{syntax} |
| 199 |
% Inserted between angle parts (degree, minute and second components). |
| 200 |
% The standard setting is empty. |
| 201 |
% \end{function} |
| 202 |
% |
| 203 |
% \begin{function} |
| 204 |
% { |
| 205 |
% fill-angle-degrees , |
| 206 |
% fill-angle-minutes , |
| 207 |
% fill-angle-seconds |
| 208 |
% } |
| 209 |
% \begin{syntax} |
| 210 |
% |fill-arc-degrees| = |true|\verb"|"|false| |
| 211 |
% \end{syntax} |
| 212 |
% Determines whether a missing angle part is zero-filled when printing an |
| 213 |
% arc. The standard setting is |false|. |
| 214 |
% \end{function} |
| 215 |
% |
| 216 |
% \section{Formatting durations} |
| 217 |
% |
| 218 |
% \begin{function} |
| 219 |
% { |
| 220 |
% \siunitx_duration:n, \siunitx_duration:e, |
| 221 |
% \siunitx_duration:nnn, \siunitx_duration:eee |
| 222 |
% } |
| 223 |
% \begin{syntax} |
| 224 |
% \cs{siunitx_duration:n} \Arg{decimal} |
| 225 |
% \cs{siunitx_duration:nnn} \Arg{hours} \Arg{minutes} \Arg{seconds} |
| 226 |
% \end{syntax} |
| 227 |
% Typeset the \meta{duration} (which may be given as separate \meta{hour}, |
| 228 |
% \meta{minute} and \meta{second} components). The \meta{duration} |
| 229 |
% (or components) may be given as expressions. The \meta{duration} should be a |
| 230 |
% number as understood by \cs{siunitx_format_number:nN}, with no uncertainty, |
| 231 |
% exponent or imaginary part. The unit symbols for hours, minutes and |
| 232 |
% seconds are |\hour|, |\minute| and |\second|, respectively. |
| 233 |
% \end{function} |
| 234 |
% |
| 235 |
% \begin{function}{duration-separator} |
| 236 |
% \begin{syntax} |
| 237 |
% |duration-separator| = \meta{separator} |
| 238 |
% \end{syntax} |
| 239 |
% Inserted between duration parts (hour, minute and second components). |
| 240 |
% The standard setting is an interword space. |
| 241 |
% \end{function} |
| 242 |
% |
| 243 |
% \begin{function}{duration-mode} |
| 244 |
% \begin{syntax} |
| 245 |
% |duration-mode| = \meta{choice} |
| 246 |
% \end{syntax} |
| 247 |
% Selects how durations are formatted: a choice from |
| 248 |
% the options |component|, |decimal| and |input|. The option |component| |
| 249 |
% means that durations will always be typeset in component (hour, minute, |
| 250 |
% second) format, whilst |decimal| means that angles are typeset as a single |
| 251 |
% decimal value. The |input| setting means that the input format |
| 252 |
% (\foreign{i.e.}~difference between \cs{siunitx_duration:n} and |
| 253 |
% \cs{siunitx_duration:nnn}) is maintained. The standard setting is |input|. |
| 254 |
% \end{function} |
| 255 |
% |
| 256 |
% \begin{function} |
| 257 |
% { |
| 258 |
% duration-unit-hour , |
| 259 |
% duration-unit-minute , |
| 260 |
% duration-unit-second |
| 261 |
% } |
| 262 |
% \begin{syntax} |
| 263 |
% |duration-unit-hour| = \meta{unit} |
| 264 |
% \end{syntax} |
| 265 |
% Sets the unit used for component hours, minutes or seconds, respectively. |
| 266 |
% \end{function} |
| 267 |
% |
| 268 |
% \begin{function} |
| 269 |
% { |
| 270 |
% fill-duration-hours , |
| 271 |
% fill-duration-minutes , |
| 272 |
% fill-duration-seconds |
| 273 |
% } |
| 274 |
% \begin{syntax} |
| 275 |
% |fill-duration-hours| = |true|\verb"|"|false| |
| 276 |
% \end{syntax} |
| 277 |
% Determines whether a missing part is zero-filled when printing an |
| 278 |
% duration in component form. The standard setting is |false|. |
| 279 |
% \end{function} |
| 280 |
% |
| 281 |
% \end{documentation} |
| 282 |
% |
| 283 |
% \begin{implementation} |
| 284 |
% |
| 285 |
% \section{\pkg{siunitx-sexagesimal} implementation} |
| 286 |
% |
| 287 |
% Start the \pkg{DocStrip} guards. |
| 288 |
% \begin{macrocode} |
| 289 |
%<*package> |
| 290 |
% \end{macrocode} |
| 291 |
% |
| 292 |
% \subsection{General mechanism} |
| 293 |
% |
| 294 |
% Identify the internal prefix. |
| 295 |
% \begin{macrocode} |
| 296 |
%<@@=siunitx_sexagesimal> |
| 297 |
% \end{macrocode} |
| 298 |
% |
| 299 |
% \begin{variable}{\l_@@_tmp_bool, \l_@@_tmp_dim, \l_@@_tmp_tl} |
| 300 |
% Scratch space. |
| 301 |
% \begin{macrocode} |
| 302 |
\bool_new:N \l_@@_tmp_bool |
| 303 |
\dim_new:N \l_@@_tmp_dim |
| 304 |
\tl_new:N \l_@@_tmp_tl |
| 305 |
% \end{macrocode} |
| 306 |
% \end{variable} |
| 307 |
% |
| 308 |
% \begin{variable} |
| 309 |
% { |
| 310 |
% \l_@@_fill_major_bool , |
| 311 |
% \l_@@_fill_inter_bool , |
| 312 |
% \l_@@_fill_minor_bool , |
| 313 |
% \l_@@_unit_major_tl , |
| 314 |
% \l_@@_unit_inter_tl , |
| 315 |
% \l_@@_unit_minor_tl , |
| 316 |
% \l_@@_force_comp_bool , |
| 317 |
% \l_@@_force_decimal_bool , |
| 318 |
% \l_@@_astronomy_bool , |
| 319 |
% \l_@@_separator_tl |
| 320 |
% } |
| 321 |
% \begin{macrocode} |
| 322 |
\keys_define:nn { siunitx } |
| 323 |
{ |
| 324 |
fill-sexagesimal-major .bool_set:N = |
| 325 |
\l_@@_fill_major_bool , |
| 326 |
fill-sexagesimal-intermediate .bool_set:N = |
| 327 |
\l_@@_fill_inter_bool , |
| 328 |
fill-sexagesimal-minor .bool_set:N = |
| 329 |
\l_@@_fill_minor_bool , |
| 330 |
sexagesimal-mode .choice: , |
| 331 |
sexagesimal-mode / component .code:n = |
| 332 |
{ |
| 333 |
\bool_set_true:N \l_@@_force_comp_bool |
| 334 |
\bool_set_false:N \l_@@_force_decimal_bool |
| 335 |
} , |
| 336 |
sexagesimal-mode / decimal .code:n = |
| 337 |
{ |
| 338 |
\bool_set_false:N \l_@@_force_comp_bool |
| 339 |
\bool_set_true:N \l_@@_force_decimal_bool |
| 340 |
} , |
| 341 |
sexagesimal-mode / input .code:n = |
| 342 |
{ |
| 343 |
\bool_set_false:N \l_@@_force_comp_bool |
| 344 |
\bool_set_false:N \l_@@_force_decimal_bool |
| 345 |
} , |
| 346 |
sexagesimal-unit-major .tl_set:N = |
| 347 |
\l_@@_unit_major_tl , |
| 348 |
sexagesimal-unit-intermediate .tl_set:N = |
| 349 |
\l_@@_unit_inter_tl , |
| 350 |
sexagesimal-unit-minor .tl_set:N = |
| 351 |
\l_@@_unit_minor_tl , |
| 352 |
sexagesimal-unit-over-decimal .bool_set:N = |
| 353 |
\l_@@_astronomy_bool , |
| 354 |
sexagesimal-separator .tl_set:N = |
| 355 |
\l_@@_separator_tl |
| 356 |
} |
| 357 |
\bool_new:N \l_@@_force_comp_bool |
| 358 |
\bool_new:N \l_@@_force_decimal_bool |
| 359 |
% \end{macrocode} |
| 360 |
% \end{variable} |
| 361 |
% |
| 362 |
% \begin{macro}{\siunitx_sexagesimal:n, \siunitx_sexagesimal:e, \@@_decimal:n} |
| 363 |
% \begin{macro}{\siunitx_sexagesimal:nnn, \siunitx_sexagesimal:eee} |
| 364 |
% \begin{macro}{\@@_comp_convert:n, \@@_comp_convert:e} |
| 365 |
% \begin{macro}{\@@_comp_convert:w} |
| 366 |
% The first step here is to force format conversion if required. Going to |
| 367 |
% a decimal is easy, going to arc format is a bit more painful: avoid |
| 368 |
% repeating calculations mainly for code readability. |
| 369 |
% \begin{macrocode} |
| 370 |
\cs_new_protected:Npn \siunitx_sexagesimal:n #1 |
| 371 |
{ |
| 372 |
\bool_if:NTF \l_siunitx_number_parse_bool |
| 373 |
{ \@@_decimal:n {#1} } |
| 374 |
{ |
| 375 |
\tl_if_blank:nF {#1} |
| 376 |
{ |
| 377 |
\tl_set:Nn \l_@@_major_tl { \ensuremath {#1} } |
| 378 |
\@@_comp_print:VVV |
| 379 |
\l_@@_major_tl |
| 380 |
\c_empty_tl |
| 381 |
\c_empty_tl |
| 382 |
} |
| 383 |
} |
| 384 |
} |
| 385 |
\cs_generate_variant:Nn \siunitx_sexagesimal:n { e } |
| 386 |
\cs_new_protected:Npn \@@_decimal:n #1 |
| 387 |
{ |
| 388 |
\bool_if:NTF \l_@@_force_comp_bool |
| 389 |
{ \@@_comp_convert:e { \fp_eval:n {#1} } } |
| 390 |
{ |
| 391 |
\siunitx_number_parse:nN {#1} \l_@@_major_tl |
| 392 |
\siunitx_number_process:NN \l_@@_major_tl \l_@@_major_tl |
| 393 |
\tl_set:Ne \l_@@_major_tl |
| 394 |
{ \siunitx_number_output:NN \l_@@_major_tl \q_nil } |
| 395 |
\@@_comp_print:VVV |
| 396 |
\l_@@_major_tl |
| 397 |
\c_empty_tl |
| 398 |
\c_empty_tl |
| 399 |
} |
| 400 |
} |
| 401 |
\cs_new_protected:Npn \siunitx_sexagesimal:nnn #1#2#3 |
| 402 |
{ |
| 403 |
\bool_if:NTF \l_siunitx_number_parse_bool |
| 404 |
{ |
| 405 |
\bool_if:NTF \l_@@_force_decimal_bool |
| 406 |
{ |
| 407 |
\siunitx_sexagesimal:e |
| 408 |
{ \fp_eval:n { #1 + ( 0 #2 ) / 60 + ( 0 #3 ) / 3600 } } |
| 409 |
} |
| 410 |
{ \@@_comp_sign:nnn {#1} {#2} {#3} } |
| 411 |
} |
| 412 |
{ |
| 413 |
\tl_set:Ne \l_@@_major_tl |
| 414 |
{ \tl_if_blank:nF {#1} { \exp_not:n { \ensuremath {#1} } } } |
| 415 |
\tl_set:Ne \l_@@_inter_tl |
| 416 |
{ \tl_if_blank:nF {#2} { \exp_not:n { \ensuremath {#2} } } } |
| 417 |
\tl_set:Ne \l_@@_minor_tl |
| 418 |
{ \tl_if_blank:nF {#3} { \exp_not:n { \ensuremath {#3} } } } |
| 419 |
\@@_comp_print:VVV |
| 420 |
\l_@@_major_tl |
| 421 |
\l_@@_inter_tl |
| 422 |
\l_@@_minor_tl |
| 423 |
} |
| 424 |
} |
| 425 |
\cs_generate_variant:Nn \siunitx_sexagesimal:nnn { eee } |
| 426 |
% \end{macrocode} |
| 427 |
% Here, the need for absolute values is to handle conversion of negative |
| 428 |
% values: the result should be exactly one sign in the integer part. For |
| 429 |
% integer input, we can control whether there are minute or second parts |
| 430 |
% at all. |
| 431 |
% \begin{macrocode} |
| 432 |
\cs_new_protected:Npn \@@_comp_convert:n #1 |
| 433 |
{ |
| 434 |
\@@_comp_convert:w #1 . \q_nil . \q_stop |
| 435 |
} |
| 436 |
\cs_generate_variant:Nn \@@_comp_convert:n { e } |
| 437 |
\cs_new_protected:Npn \@@_comp_convert:w #1 . #2 . #3 \q_stop |
| 438 |
{ |
| 439 |
\quark_if_nil:nTF {#2} |
| 440 |
{ |
| 441 |
\siunitx_sexagesimal:eee |
| 442 |
{ \fp_eval:n { trunc(#1,0) } } |
| 443 |
{ \bool_if:NT \l_@@_fill_inter_bool { 0 } } |
| 444 |
{ \bool_if:NT \l_@@_fill_minor_bool { 0 } } |
| 445 |
} |
| 446 |
{ |
| 447 |
\siunitx_sexagesimal:eee |
| 448 |
{ \fp_eval:n { trunc(#1.#2,0) } } |
| 449 |
{ \fp_eval:n { abs(trunc((#1.#2 - trunc(#1,0)) * 60,0)) } } |
| 450 |
{ |
| 451 |
\fp_eval:n |
| 452 |
{ |
| 453 |
abs |
| 454 |
( |
| 455 |
(#1.#2 - trunc(#1.#2,0)) * 60 |
| 456 |
- trunc((#1.#2 - trunc(#1.#2,0)) * 60,0) |
| 457 |
) |
| 458 |
* 60 |
| 459 |
} |
| 460 |
} |
| 461 |
} |
| 462 |
} |
| 463 |
% \end{macrocode} |
| 464 |
% \end{macro} |
| 465 |
% \end{macro} |
| 466 |
% \end{macro} |
| 467 |
% \end{macro} |
| 468 |
% |
| 469 |
% \begin{variable}{\c_@@_parts_tl} |
| 470 |
% For mappings. |
| 471 |
% \begin{macrocode} |
| 472 |
\clist_const:Nn \c_@@_parts_tl { major , inter , minor } |
| 473 |
% \end{macrocode} |
| 474 |
% \end{variable} |
| 475 |
% |
| 476 |
% \begin{variable}{\l_@@_major_tl, \l_@@_inter_tl, \l_@@_minor_tl} |
| 477 |
% Space for formatting parsed numbers. |
| 478 |
% \begin{macrocode} |
| 479 |
\tl_new:N \l_@@_major_tl |
| 480 |
\tl_new:N \l_@@_inter_tl |
| 481 |
\tl_new:N \l_@@_minor_tl |
| 482 |
% \end{macrocode} |
| 483 |
% \end{variable} |
| 484 |
% |
| 485 |
% \begin{variable}{\l_@@_sign_tl} |
| 486 |
% For the \enquote{sign shuffle}. |
| 487 |
% \begin{macrocode} |
| 488 |
\tl_new:N \l_@@_sign_tl |
| 489 |
% \end{macrocode} |
| 490 |
% \end{variable} |
| 491 |
% |
| 492 |
% \begin{variable}{\l_@@_signed_bool} |
| 493 |
% To check that only one sign is seen in arc mode. |
| 494 |
% \begin{macrocode} |
| 495 |
\bool_new:N \l_@@_signed_bool |
| 496 |
% \end{macrocode} |
| 497 |
% \end{variable} |
| 498 |
% |
| 499 |
% \begin{macro}{\@@_suppress_comp:, \@@_suppress_exp:, \@@_suppress_uncert:,} |
| 500 |
% Pre-compilation of keys to suppress uncertainties and exponents, |
| 501 |
% and |
| 502 |
% \begin{macrocode} |
| 503 |
\keys_precompile:nnN |
| 504 |
{ siunitx } |
| 505 |
{ input-comparators = } |
| 506 |
\l_@@_tmp_tl |
| 507 |
\cs_new_protected:Npe \@@_suppress_comp: |
| 508 |
{ \exp_not:V \l_@@_tmp_tl } |
| 509 |
\keys_precompile:nnN |
| 510 |
{ siunitx } |
| 511 |
{ input-exponent-markers = } |
| 512 |
\l_@@_tmp_tl |
| 513 |
\cs_new_protected:Npe \@@_suppress_exp: |
| 514 |
{ \exp_not:V \l_@@_tmp_tl } |
| 515 |
\keys_precompile:nnN |
| 516 |
{ siunitx } |
| 517 |
{ |
| 518 |
input-close-uncertainty = , |
| 519 |
input-open-uncertainty = , |
| 520 |
input-uncertainty-signs = |
| 521 |
} |
| 522 |
\l_@@_tmp_tl |
| 523 |
\cs_new_protected:Npe \@@_suppress_uncert: |
| 524 |
{ \exp_not:V \l_@@_tmp_tl } |
| 525 |
% \end{macrocode} |
| 526 |
% \end{macro} |
| 527 |
% |
| 528 |
% \begin{macro}{\@@_comp_sign:nnn} |
| 529 |
% \begin{macro}{\@@_comp_sign:nn} |
| 530 |
% \begin{macro}{\@@_comp_sign_auxi:, \@@_comp_sign_auxii:} |
| 531 |
% \begin{macro}{\@@_extract_sign:nnnnnnnn} |
| 532 |
% \begin{macro}[EXP]{\@@_sign:nnnnnnn} |
| 533 |
% To get the sign in the right place whilst dealing with zero filling |
| 534 |
% means doing some shuffling. That means doing processing of each number |
| 535 |
% manually. For degrees, auto-conversion can give |-0|, which needs to be |
| 536 |
% picked up early to set the sign. A bit of shuffling is needed as only |
| 537 |
% the seconds argument is permitted to have an uncertainty. |
| 538 |
% \begin{macrocode} |
| 539 |
\cs_new_protected:Npn \@@_comp_sign:nnn #1#2#3 |
| 540 |
{ |
| 541 |
\group_begin: |
| 542 |
\tl_clear:N \l_@@_sign_tl |
| 543 |
\bool_set_false:N \l_@@_signed_bool |
| 544 |
\group_begin: |
| 545 |
\@@_suppress_exp: |
| 546 |
\@@_suppress_uncert: |
| 547 |
\str_if_eq:nnTF {#1} { -0 } |
| 548 |
{ |
| 549 |
\@@_comp_sign:nn { } { major } |
| 550 |
\@@_suppress_comp: |
| 551 |
\tl_set:Nn \l_@@_sign_tl { - } |
| 552 |
\bool_set_true:N \l_@@_signed_bool |
| 553 |
} |
| 554 |
{ \@@_comp_sign:nn {#1} { major } } |
| 555 |
\@@_comp_sign:nn {#2} { inter } |
| 556 |
\tl_set:Ne \l_@@_tmp_tl |
| 557 |
{ |
| 558 |
\tl_set:Nn \exp_not:N \l_@@_sign_tl |
| 559 |
{ \exp_not:V \l_@@_sign_tl } |
| 560 |
\tl_set:Nn \exp_not:N \l_@@_major_tl |
| 561 |
{ \exp_not:V \l_@@_major_tl } |
| 562 |
\tl_set:Nn \exp_not:N \l_@@_inter_tl |
| 563 |
{ \exp_not:V \l_@@_inter_tl } |
| 564 |
\exp_not:c |
| 565 |
{ |
| 566 |
bool_set_ |
| 567 |
\bool_if:NTF \l_@@_signed_bool |
| 568 |
{ true } |
| 569 |
{ false } |
| 570 |
:N |
| 571 |
} |
| 572 |
\exp_not:N \l_@@_signed_bool |
| 573 |
} |
| 574 |
\exp_after:wN \group_end: \l_@@_tmp_tl |
| 575 |
\@@_comp_sign:nn {#3} { minor } |
| 576 |
\tl_if_empty:NF \l_@@_sign_tl |
| 577 |
{ |
| 578 |
\clist_map_function:NN \c_@@_parts_tl |
| 579 |
\@@_comp_sign_auxi:n |
| 580 |
} |
| 581 |
\clist_map_function:NN \c_@@_parts_tl \@@_comp_sign_auxii:n |
| 582 |
\@@_comp_print:VVV |
| 583 |
\l_@@_major_tl |
| 584 |
\l_@@_inter_tl |
| 585 |
\l_@@_minor_tl |
| 586 |
\group_end: |
| 587 |
} |
| 588 |
\cs_new_protected:Npn \@@_comp_sign:nn #1#2 |
| 589 |
{ |
| 590 |
\tl_if_blank:nTF {#1} |
| 591 |
{ |
| 592 |
\bool_if:cTF { l_@@_fill_ #2 _bool } |
| 593 |
{ |
| 594 |
\tl_set:cn { l_@@_ #2 _tl } |
| 595 |
{ { } { } { 0 } { } { } { } { 0 } } |
| 596 |
} |
| 597 |
{ \tl_clear:c { l_@@_ #2 _tl } } |
| 598 |
} |
| 599 |
{ |
| 600 |
\siunitx_number_parse:nN {#1} \l_@@_tmp_tl |
| 601 |
\tl_if_empty:NF \l_@@_tmp_tl |
| 602 |
{ |
| 603 |
\exp_after:wN \@@_extract_sign:nnnnnnnn \l_@@_tmp_tl {#2} |
| 604 |
\bool_set_true:N \l_@@_signed_bool |
| 605 |
} |
| 606 |
} |
| 607 |
} |
| 608 |
\cs_new_protected:Npn \@@_comp_sign_auxi:n #1 |
| 609 |
{ |
| 610 |
\tl_if_empty:cF { l_@@_ #1 _tl } |
| 611 |
{ |
| 612 |
\tl_set:ce { l_@@_ #1 _tl } |
| 613 |
{ |
| 614 |
{ } |
| 615 |
{ \exp_not:V \l_@@_sign_tl } |
| 616 |
\exp_after:wN \exp_after:wN \exp_after:wN |
| 617 |
\@@_sign:nnnnnnn |
| 618 |
\cs:w l_@@_ #1 _tl \cs_end: |
| 619 |
} |
| 620 |
\clist_map_break: |
| 621 |
} |
| 622 |
} |
| 623 |
\cs_new_protected:Npn \@@_comp_sign_auxii:n #1 |
| 624 |
{ |
| 625 |
\tl_if_empty:cF { l_@@_ #1 _tl } |
| 626 |
{ |
| 627 |
\bool_lazy_and:nnF |
| 628 |
{ \l_@@_force_comp_bool } |
| 629 |
{ ! \str_if_eq_p:nn {#1} { minor } } |
| 630 |
{ |
| 631 |
\siunitx_number_process:cc |
| 632 |
{ l_@@_ #1 _tl } { l_@@_ #1 _tl } |
| 633 |
} |
| 634 |
\tl_set:ce { l_@@_ #1 _tl } |
| 635 |
{ |
| 636 |
\siunitx_number_output:cN |
| 637 |
{ l_@@_ #1 _tl } \q_nil |
| 638 |
} |
| 639 |
} |
| 640 |
} |
| 641 |
\cs_new_protected:Npn \@@_extract_sign:nnnnnnnn #1#2#3#4#5#6#7#8 |
| 642 |
{ |
| 643 |
\tl_if_blank:nTF {#2} |
| 644 |
{ \tl_set_eq:cN { l_@@_ #8 _tl } \l_@@_tmp_tl } |
| 645 |
{ |
| 646 |
\bool_if:NTF \l_@@_signed_bool |
| 647 |
{ \msg_error:nnn { siunitx } { sexagesimal-multi-sign } } |
| 648 |
{ \tl_set:Nn \l_@@_sign_tl {#2} } |
| 649 |
\tl_set:cn { l_@@_ #8 _tl } |
| 650 |
{ {#1} { } {#3} {#4} {#5} {#6} {#7} } |
| 651 |
\@@_suppress_comp: |
| 652 |
} |
| 653 |
} |
| 654 |
\cs_new:Npn \@@_sign:nnnnnnn #1#2#3#4#5#6#7 |
| 655 |
{ \exp_not:n { {#3} {#4} {#5} {#6} {#7} } } |
| 656 |
% \end{macrocode} |
| 657 |
% \end{macro} |
| 658 |
% \end{macro} |
| 659 |
% \end{macro} |
| 660 |
% \end{macro} |
| 661 |
% \end{macro} |
| 662 |
% |
| 663 |
% \begin{variable}{\l_@@_marker_box, \l_@@_unit_box} |
| 664 |
% For \enquote{astronomy style} output. |
| 665 |
% \begin{macrocode} |
| 666 |
\box_new:N \l_@@_marker_box |
| 667 |
\box_new:N \l_@@_unit_box |
| 668 |
% \end{macrocode} |
| 669 |
% \end{variable} |
| 670 |
% |
| 671 |
% \begin{macro} |
| 672 |
% { |
| 673 |
% \@@_comp_print:nnn, \@@_comp_print:VVV, |
| 674 |
% \@@_comp_print_auxi:nnn, \@@_comp_print_auxi:nVn |
| 675 |
% } |
| 676 |
% \begin{macro}{\@@_comp_print_auxii:w} |
| 677 |
% \begin{macro}{\@@_comp_print_auxiii:nw} |
| 678 |
% \begin{macro}{\@@_comp_print_auxiv:nnnnn} |
| 679 |
% \begin{macro}{\@@_comp_print_auxv:n} |
| 680 |
% \begin{macro}{\@@_comp_print_auxvi:NN} |
| 681 |
% \begin{macro}{\@@_comp_print_auxvii:nw} |
| 682 |
% \begin{macro}{\@@_comp_print_auxiix:nw} |
| 683 |
% \begin{macro}{\@@_comp_print_auxix:nn} |
| 684 |
% The final stage of printing an angle is to put together the three parts: |
| 685 |
% this works even for decimal angles as they will blank arguments for the |
| 686 |
% other two parts The need to handle astronomy-style formatting means that |
| 687 |
% the number has to be decomposed into parts. |
| 688 |
% \begin{macrocode} |
| 689 |
\cs_new_protected:Npn \@@_comp_print:nnn #1#2#3 |
| 690 |
{ |
| 691 |
\@@_comp_print_auxi:nVn {#1} |
| 692 |
\l_@@_unit_major_tl {#2#3} |
| 693 |
\@@_comp_print_auxi:nVn {#2} |
| 694 |
\l_@@_unit_inter_tl {#3} |
| 695 |
\@@_comp_print_auxi:nVn {#3} |
| 696 |
\l_@@_unit_minor_tl { } |
| 697 |
} |
| 698 |
\cs_generate_variant:Nn \@@_comp_print:nnn { VVV } |
| 699 |
\cs_new_protected:Npn \@@_comp_print_auxi:nnn #1#2#3 |
| 700 |
{ |
| 701 |
\tl_if_blank:nF {#1} |
| 702 |
{ |
| 703 |
\bool_if:NTF \l_siunitx_number_parse_bool |
| 704 |
{ |
| 705 |
\bool_if:NTF \l_@@_astronomy_bool |
| 706 |
{ \@@_comp_print_auxii:nw {#2} #1 \q_stop } |
| 707 |
{ \@@_comp_print_auxvii:nw {#2} #1 \q_stop } |
| 708 |
} |
| 709 |
{ \@@_comp_print_auxix:nn {#1} {#2} } |
| 710 |
\tl_if_blank:nF {#3} |
| 711 |
{ |
| 712 |
\nobreak |
| 713 |
\l_@@_separator_tl |
| 714 |
} |
| 715 |
} |
| 716 |
} |
| 717 |
\cs_generate_variant:Nn \@@_comp_print_auxi:nnn { nV } |
| 718 |
% \end{macrocode} |
| 719 |
% To align the two parts of the astronomy-style marker, we need to allow |
| 720 |
% for the |\scriptspace|. |
| 721 |
% \begin{macrocode} |
| 722 |
\cs_new_protected:Npn \@@_comp_print_auxii:nw |
| 723 |
#1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_stop |
| 724 |
{ |
| 725 |
\@@_comp_print_auxiii:nw {#6} #7 \q_stop |
| 726 |
{#2#3#4} {#5} {#1} |
| 727 |
} |
| 728 |
\cs_new_protected:Npn \@@_comp_print_auxiii:nw |
| 729 |
#1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_stop |
| 730 |
{ \@@_comp_print_auxiv:nnnnn {#1} {#6#7} } |
| 731 |
\cs_new_protected:Npn \@@_comp_print_auxiv:nnnnn #1#2#3#4#5 |
| 732 |
{ |
| 733 |
\mode_if_math:TF |
| 734 |
{ \bool_set_true:N \l_@@_tmp_bool } |
| 735 |
{ \bool_set_false:N \l_@@_tmp_bool } |
| 736 |
\siunitx_print_number:n {#3} |
| 737 |
\tl_if_blank:nTF {#1} |
| 738 |
{ \@@_comp_print_auxix:nn {#2} {#5} } |
| 739 |
{ |
| 740 |
\hbox_set:Nn \l_@@_marker_box |
| 741 |
{ |
| 742 |
\@@_comp_print_auxv:n |
| 743 |
{ \siunitx_print_number:n {#4} } |
| 744 |
} |
| 745 |
\hbox_set:Nn \l_@@_unit_box |
| 746 |
{ |
| 747 |
\@@_comp_print_auxv:n |
| 748 |
{ |
| 749 |
\siunitx_unit_format:nN {#5} \l_@@_tmp_tl |
| 750 |
\siunitx_print_unit:V \l_@@_tmp_tl |
| 751 |
\skip_horizontal:n { -\scriptspace } |
| 752 |
} |
| 753 |
} |
| 754 |
\dim_compare:nNnTF { \box_wd:N \l_@@_marker_box } > |
| 755 |
{ \box_wd:N \l_@@_unit_box } |
| 756 |
{ |
| 757 |
\@@_comp_print_auxvi:NN |
| 758 |
\l_@@_marker_box |
| 759 |
\l_@@_unit_box |
| 760 |
} |
| 761 |
{ |
| 762 |
\@@_comp_print_auxvi:NN |
| 763 |
\l_@@_unit_box |
| 764 |
\l_@@_marker_box |
| 765 |
} |
| 766 |
\hbox_set_to_wd:Nnn \l_@@_marker_box |
| 767 |
\l_@@_tmp_dim |
| 768 |
{ |
| 769 |
\hbox_overlap_right:n |
| 770 |
{ \box_use_drop:N \l_@@_marker_box } |
| 771 |
\hbox_overlap_right:n |
| 772 |
{ \box_use_drop:N \l_@@_unit_box } |
| 773 |
\tex_hfil:D |
| 774 |
} |
| 775 |
\box_use:N \l_@@_marker_box |
| 776 |
\tex_kern:D \scriptspace |
| 777 |
\siunitx_print_number:n {#1#2} |
| 778 |
} |
| 779 |
} |
| 780 |
\cs_new_protected:Npn \@@_comp_print_auxv:n #1 |
| 781 |
{ |
| 782 |
\bool_if:NTF \l_@@_tmp_bool |
| 783 |
{ \ensuremath } |
| 784 |
{ \use:n } |
| 785 |
{#1} |
| 786 |
} |
| 787 |
\cs_new_protected:Npn \@@_comp_print_auxvi:NN #1#2 |
| 788 |
{ |
| 789 |
\dim_set:Nn \l_@@_tmp_dim { \box_wd:N #1 } |
| 790 |
\hbox_set_to_wd:Nnn #2 |
| 791 |
\l_@@_tmp_dim |
| 792 |
{ |
| 793 |
\tex_hss:D |
| 794 |
\hbox_unpack_drop:N #2 |
| 795 |
\tex_hss:D |
| 796 |
} |
| 797 |
} |
| 798 |
\cs_new_protected:Npn \@@_comp_print_auxvii:nw |
| 799 |
#1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_stop |
| 800 |
{ \@@_comp_print_auxiix:nw {#1} {#2#3#4#5#6} #7 \q_stop } |
| 801 |
\cs_new_protected:Npn \@@_comp_print_auxiix:nw |
| 802 |
#1#2#3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8 \q_stop |
| 803 |
{ \@@_comp_print_auxix:nn {#2#7#8} {#1} } |
| 804 |
\cs_new_protected:Npn \@@_comp_print_auxix:nn #1#2 |
| 805 |
{ |
| 806 |
\group_begin: |
| 807 |
\siunitx_unit_options_apply:n {#2} |
| 808 |
\siunitx_unit_format:nN {#2} \l_@@_tmp_tl |
| 809 |
\siunitx_quantity_print:nV {#1} \l_@@_tmp_tl |
| 810 |
\group_end: |
| 811 |
} |
| 812 |
% \end{macrocode} |
| 813 |
% \end{macro} |
| 814 |
% \end{macro} |
| 815 |
% \end{macro} |
| 816 |
% \end{macro} |
| 817 |
% \end{macro} |
| 818 |
% \end{macro} |
| 819 |
% \end{macro} |
| 820 |
% \end{macro} |
| 821 |
% \end{macro} |
| 822 |
% |
| 823 |
% \begin{macrocode} |
| 824 |
\msg_new:nnnn { siunitx } { sexagesimal-multi-sign } |
| 825 |
{ Multiple~signs~given~for~sexagesimal~components! } |
| 826 |
{ |
| 827 |
A~sexagesimal~value~given~as~components~should~have~at~most~one~sign:~ |
| 828 |
only~the~first~sign~will~be~used. |
| 829 |
} |
| 830 |
% \end{macrocode} |
| 831 |
% |
| 832 |
% \subsection{Angles} |
| 833 |
% |
| 834 |
% Identify the internal prefix. |
| 835 |
% \begin{macrocode} |
| 836 |
%<@@=siunitx_angle> |
| 837 |
% \end{macrocode} |
| 838 |
% |
| 839 |
% \begin{variable} |
| 840 |
% { |
| 841 |
% \l_@@_symbol_degree_tl , |
| 842 |
% \l_@@_symbol_minute_tl , |
| 843 |
% \l_@@_symbol_second_tl , |
| 844 |
% \l_@@_force_arc_bool , |
| 845 |
% \l_@@_force_decimal_bool , |
| 846 |
% \l_@@_astronomy_bool , |
| 847 |
% \l_@@_separator_tl , |
| 848 |
% \l_@@_fill_degrees_bool , |
| 849 |
% \l_@@_fill_minutes_bool , |
| 850 |
% \l_@@_fill_seconds_bool |
| 851 |
% } |
| 852 |
% \begin{macrocode} |
| 853 |
\keys_define:nn { siunitx } |
| 854 |
{ |
| 855 |
angle-mode .choice: , |
| 856 |
angle-mode / arc .code:n = |
| 857 |
{ |
| 858 |
\bool_set_true:N \l_@@_force_arc_bool |
| 859 |
\bool_set_false:N \l_@@_force_decimal_bool |
| 860 |
} , |
| 861 |
angle-mode / decimal .code:n = |
| 862 |
{ |
| 863 |
\bool_set_false:N \l_@@_force_arc_bool |
| 864 |
\bool_set_true:N \l_@@_force_decimal_bool |
| 865 |
} , |
| 866 |
angle-mode / input .code:n = |
| 867 |
{ |
| 868 |
\bool_set_false:N \l_@@_force_arc_bool |
| 869 |
\bool_set_false:N \l_@@_force_decimal_bool |
| 870 |
} , |
| 871 |
angle-symbol-degree .tl_set:N = |
| 872 |
\l_@@_symbol_degree_tl , |
| 873 |
angle-symbol-minute .tl_set:N = |
| 874 |
\l_@@_symbol_minute_tl , |
| 875 |
angle-symbol-second .tl_set:N = |
| 876 |
\l_@@_symbol_second_tl , |
| 877 |
angle-symbol-over-decimal .bool_set:N = |
| 878 |
\l_@@_astronomy_bool , |
| 879 |
angle-separator .tl_set:N = |
| 880 |
\l_@@_separator_tl , |
| 881 |
fill-angle-degrees .bool_set:N = |
| 882 |
\l_@@_fill_degrees_bool , |
| 883 |
fill-angle-minutes .bool_set:N = |
| 884 |
\l_@@_fill_minutes_bool , |
| 885 |
fill-angle-seconds .bool_set:N = |
| 886 |
\l_@@_fill_seconds_bool , |
| 887 |
} |
| 888 |
\bool_new:N \l_@@_force_arc_bool |
| 889 |
\bool_new:N \l_@@_force_decimal_bool |
| 890 |
% \end{macrocode} |
| 891 |
% \end{variable} |
| 892 |
% |
| 893 |
% \begin{macro}{\siunitx_angle:n, \siunitx_angle:e} |
| 894 |
% \begin{macro}{\siunitx_angle:nnn, \siunitx_angle:eee} |
| 895 |
% \begin{macro}{\@@_aux:} |
| 896 |
% \begin{macrocode} |
| 897 |
\cs_new_protected:Npn \siunitx_angle:n #1 |
| 898 |
{ |
| 899 |
\group_begin: |
| 900 |
\@@_aux: |
| 901 |
\siunitx_sexagesimal:n {#1} |
| 902 |
\group_end: |
| 903 |
} |
| 904 |
\cs_generate_variant:Nn \siunitx_angle:n { e , x } |
| 905 |
\cs_new_protected:Npn \siunitx_angle:nnn #1#2#3 |
| 906 |
{ |
| 907 |
\group_begin: |
| 908 |
\@@_aux: |
| 909 |
\siunitx_sexagesimal:nnn {#1} {#2} {#3} |
| 910 |
\group_end: |
| 911 |
} |
| 912 |
\cs_generate_variant:Nn \siunitx_angle:nnn { eee , xxx } |
| 913 |
\cs_new_protected:Npn \@@_aux: |
| 914 |
{ |
| 915 |
\keys_set:ne { siunitx } |
| 916 |
{ |
| 917 |
fill-sexagesimal-major = |
| 918 |
\bool_if:NTF \l_@@_fill_degrees_bool { true } { false } , |
| 919 |
fill-sexagesimal-intermediate = |
| 920 |
\bool_if:NTF \l_@@_fill_minutes_bool { true } { false } , |
| 921 |
fill-sexagesimal-minor = |
| 922 |
\bool_if:NTF \l_@@_fill_seconds_bool { true } { false } , |
| 923 |
sexagesimal-mode = |
| 924 |
\bool_if:NTF \l_@@_force_arc_bool |
| 925 |
{ component } |
| 926 |
{ |
| 927 |
\bool_if:NTF \l_@@_force_decimal_bool |
| 928 |
{ decimal } |
| 929 |
{ input } |
| 930 |
} , |
| 931 |
sexagesimal-unit-major = |
| 932 |
{ \exp_not:V \l_@@_symbol_degree_tl } , |
| 933 |
sexagesimal-unit-intermediate = |
| 934 |
{ \exp_not:V \l_@@_symbol_minute_tl } , |
| 935 |
sexagesimal-unit-minor = |
| 936 |
{ \exp_not:V \l_@@_symbol_second_tl } , |
| 937 |
sexagesimal-unit-over-decimal = |
| 938 |
\bool_if:NTF \l_@@_astronomy_bool { true } { false } , |
| 939 |
sexagesimal-separator = |
| 940 |
{ \exp_not:V \l_@@_separator_tl } |
| 941 |
} |
| 942 |
} |
| 943 |
% \end{macrocode} |
| 944 |
% \end{macro} |
| 945 |
% \end{macro} |
| 946 |
% \end{macro} |
| 947 |
% |
| 948 |
% \subsection{Durations} |
| 949 |
% |
| 950 |
% Identify the internal prefix. |
| 951 |
% \begin{macrocode} |
| 952 |
%<@@=siunitx_duration> |
| 953 |
% \end{macrocode} |
| 954 |
% |
| 955 |
% \begin{variable} |
| 956 |
% { |
| 957 |
% \l_@@_unit_hour_tl , |
| 958 |
% \l_@@_unit_minute_tl , |
| 959 |
% \l_@@_unit_second_tl , |
| 960 |
% \l_@@_force_arc_bool , |
| 961 |
% \l_@@_force_decimal_bool , |
| 962 |
% \l_@@_separator_tl , |
| 963 |
% \l_@@_fill_hours_bool , |
| 964 |
% \l_@@_fill_minutes_bool , |
| 965 |
% \l_@@_fill_seconds_bool |
| 966 |
% } |
| 967 |
% \begin{macrocode} |
| 968 |
\keys_define:nn { siunitx } |
| 969 |
{ |
| 970 |
duration-mode .choice: , |
| 971 |
duration-mode / component .code:n = |
| 972 |
{ |
| 973 |
\bool_set_true:N \l_@@_force_comp_bool |
| 974 |
\bool_set_false:N \l_@@_force_decimal_bool |
| 975 |
} , |
| 976 |
duration-mode / decimal .code:n = |
| 977 |
{ |
| 978 |
\bool_set_false:N \l_@@_force_comp_bool |
| 979 |
\bool_set_true:N \l_@@_force_decimal_bool |
| 980 |
} , |
| 981 |
duration-mode / input .code:n = |
| 982 |
{ |
| 983 |
\bool_set_false:N \l_@@_force_comp_bool |
| 984 |
\bool_set_false:N \l_@@_force_decimal_bool |
| 985 |
} , |
| 986 |
duration-unit-hour .tl_set:N = |
| 987 |
\l_@@_symbol_hour_tl , |
| 988 |
duration-unit-minute .tl_set:N = |
| 989 |
\l_@@_symbol_minute_tl , |
| 990 |
duration-unit-second .tl_set:N = |
| 991 |
\l_@@_symbol_second_tl , |
| 992 |
duration-separator .tl_set:N = |
| 993 |
\l_@@_separator_tl , |
| 994 |
fill-duration-hours .bool_set:N = |
| 995 |
\l_@@_fill_hours_bool , |
| 996 |
fill-duration-minutes .bool_set:N = |
| 997 |
\l_@@_fill_minutes_bool , |
| 998 |
fill-duration-seconds .bool_set:N = |
| 999 |
\l_@@_fill_seconds_bool , |
| 1000 |
} |
| 1001 |
\bool_new:N \l_@@_force_comp_bool |
| 1002 |
\bool_new:N \l_@@_force_decimal_bool |
| 1003 |
% \end{macrocode} |
| 1004 |
% \end{variable} |
| 1005 |
% |
| 1006 |
% \begin{macro}{\siunitx_duration:n, \siunitx_duration:e} |
| 1007 |
% \begin{macro}{\siunitx_duration:nnn, \siunitx_duration:eee} |
| 1008 |
% \begin{macro}{\@@_aux:} |
| 1009 |
% \begin{macrocode} |
| 1010 |
\cs_new_protected:Npn \siunitx_duration:n #1 |
| 1011 |
{ |
| 1012 |
\group_begin: |
| 1013 |
\@@_aux: |
| 1014 |
\siunitx_sexagesimal:n {#1} |
| 1015 |
\group_end: |
| 1016 |
} |
| 1017 |
\cs_generate_variant:Nn \siunitx_duration:n { e } |
| 1018 |
\cs_new_protected:Npn \siunitx_duration:nnn #1#2#3 |
| 1019 |
{ |
| 1020 |
\group_begin: |
| 1021 |
\@@_aux: |
| 1022 |
\siunitx_sexagesimal:nnn {#1} {#2} {#3} |
| 1023 |
\group_end: |
| 1024 |
} |
| 1025 |
\cs_generate_variant:Nn \siunitx_duration:nnn { eee } |
| 1026 |
\cs_new_protected:Npn \@@_aux: |
| 1027 |
{ |
| 1028 |
\keys_set:ne { siunitx } |
| 1029 |
{ |
| 1030 |
fill-sexagesimal-major = |
| 1031 |
\bool_if:NTF \l_@@_fill_hours_bool { true } { false } , |
| 1032 |
fill-sexagesimal-intermediate = |
| 1033 |
\bool_if:NTF \l_@@_fill_minutes_bool { true } { false } , |
| 1034 |
fill-sexagesimal-minor = |
| 1035 |
\bool_if:NTF \l_@@_fill_seconds_bool { true } { false } , |
| 1036 |
sexagesimal-mode = |
| 1037 |
\bool_if:NTF \l_@@_force_comp_bool |
| 1038 |
{ component } |
| 1039 |
{ |
| 1040 |
\bool_if:NTF \l_@@_force_decimal_bool |
| 1041 |
{ decimal } |
| 1042 |
{ input } |
| 1043 |
} , |
| 1044 |
sexagesimal-unit-major = |
| 1045 |
{ \exp_not:V \l_@@_symbol_hour_tl } , |
| 1046 |
sexagesimal-unit-intermediate = |
| 1047 |
{ \exp_not:V \l_@@_symbol_minute_tl } , |
| 1048 |
sexagesimal-unit-minor = |
| 1049 |
{ \exp_not:V \l_@@_symbol_second_tl } , |
| 1050 |
sexagesimal-separator = |
| 1051 |
{ \exp_not:V \l_@@_separator_tl } |
| 1052 |
} |
| 1053 |
} |
| 1054 |
% \end{macrocode} |
| 1055 |
% \end{macro} |
| 1056 |
% \end{macro} |
| 1057 |
% \end{macro} |
| 1058 |
% |
| 1059 |
% \subsection{Deprecated options} |
| 1060 |
% |
| 1061 |
% \begin{macrocode} |
| 1062 |
\msg_new:nnn { siunitx } { angle-option-deprecated } |
| 1063 |
{ |
| 1064 |
Option~"#1"~has~been~deprecated~in~this~release.\\ \\ |
| 1065 |
Set~the~"quantity-product"~option~for~the~units~ |
| 1066 |
\token_to_str:N \arcminute,~\arcsecond\ and~\degree\ instead. |
| 1067 |
} |
| 1068 |
\keys_define:nn { siunitx } |
| 1069 |
{ |
| 1070 |
number-angle-product .code:n = |
| 1071 |
{ |
| 1072 |
\msg_info:nnn { siunitx } { angle-option-deprecated } |
| 1073 |
{ number-angle-product } |
| 1074 |
\siunitx_unit_options_declare:Nn \arcminute |
| 1075 |
{ quantity-product = {#1} } |
| 1076 |
\siunitx_unit_options_declare:Nn \arcsecond |
| 1077 |
{ quantity-product = {#1} } |
| 1078 |
\siunitx_unit_options_declare:Nn \degree |
| 1079 |
{ quantity-product = {#1} } |
| 1080 |
} |
| 1081 |
} |
| 1082 |
% \end{macrocode} |
| 1083 |
% |
| 1084 |
% \subsection{Standard settings for module options} |
| 1085 |
% |
| 1086 |
% \begin{macrocode} |
| 1087 |
\keys_set:nn { siunitx } |
| 1088 |
{ |
| 1089 |
angle-mode = input , |
| 1090 |
angle-symbol-degree = \degree , |
| 1091 |
angle-symbol-minute = \arcminute , |
| 1092 |
angle-symbol-over-decimal = false , |
| 1093 |
angle-symbol-second = \arcsecond , |
| 1094 |
angle-separator = , |
| 1095 |
duration-mode = input , |
| 1096 |
duration-unit-hour = \hour , |
| 1097 |
duration-unit-minute = \minute , |
| 1098 |
duration-unit-second = \second , |
| 1099 |
duration-separator = |
| 1100 |
\TextOrMath { \space } { \ } , |
| 1101 |
fill-angle-degrees = false , |
| 1102 |
fill-angle-minutes = false , |
| 1103 |
fill-angle-seconds = false , |
| 1104 |
fill-duration-hours = false , |
| 1105 |
fill-duration-minutes = false , |
| 1106 |
fill-duration-seconds = false , |
| 1107 |
fill-sexagesimal-major = false , |
| 1108 |
fill-sexagesimal-intermediate = false , |
| 1109 |
fill-sexagesimal-minor = false , |
| 1110 |
sexagesimal-mode = input , |
| 1111 |
sexagesimal-unit-major = , |
| 1112 |
sexagesimal-unit-intermediate = , |
| 1113 |
sexagesimal-unit-minor = , |
| 1114 |
sexagesimal-unit-over-decimal = false , |
| 1115 |
sexagesimal-separator = |
| 1116 |
} |
| 1117 |
% \end{macrocode} |
| 1118 |
% |
| 1119 |
% \begin{macrocode} |
| 1120 |
%</package> |
| 1121 |
% \end{macrocode} |
| 1122 |
% |
| 1123 |
% \end{implementation} |
| 1124 |
% |
| 1125 |
% \PrintIndex |