I have a large scientific manuscript that I am trying to make screen-reader friendly. In many places, I have written quantities such as \qty{32.5(12)}{\micro\gram\per\milli\litre}
I am trying to "redefine" the siunitx macros so that when I use them, they automatically contain the alt text/actual text. I tried to take inspiration from this previous post: Can I redefine a command to contain itself?. Here is what I have attempted:
\documentclass{article} \usepackage[separate-uncertainty=true, mode=text]{siunitx} \usepackage{accsupp} \let\oldmilli\milli%copying the \milli command into \oldmilli \renewcommand{\milli}{%renewing the \milli command \BeginAccSupp{ActualText="milli"}%Defining how I want to screen reader to read this. \OriginalMilli%Go back to using the old \milli \EndAccSupp{}% } \begin{document} \qty{32.5(12)}{\milli\gram\per\gram} \end{document} I tried to experiment with \milli first and then proceed to other units, but already I run into this issue:
! LaTeX Error: Command \milli undefined. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. Why does LaTeX say this is undefined when siunitx has already defined this for us?
I know I can simply rewrite this code as:
\documentclass{article} \usepackage[separate-uncertainty=true, mode=text]{siunitx} \usepackage{accsupp} \begin{document} \BeginAccSupp{ActualText="Thirty two point five plus minus one point two milli gram per gram"} \qty{32.5(12)}{\milli\gram\per\gram} \EndAccSupp{} \end{document} But doing this for the hundreds of quantities noted in the manuscript is simply impractical. Any suggestions? I'm not a power user, so please consider that when you give your suggestion.
P.S: I am using pdfTeX as that's what I have learnt and used for many years. Current version is:
pdfTeX 3.141592653-2.6-1.40.28 (TeX Live 2025)Siunitxversion is 2025-05-17 v3.4.11accsupppackage version is 2019/12/05 v0.6
\milliis not a unit but a prefix, so I fear it is not so easy ...