我需要为没有盲文的盲人写额外的版本

我需要为没有盲文的盲人写额外的版本

我正在编写一个小数学脚本,我还需要为盲人制作一个版本,但没有盲文。例如,\frac{1}{2}不应该是文字分数,而应该是1 over 2。我可以覆盖\frac命令以按照我想要的方式编写它吗?如果可以,怎么做?我被告知他们正在使用软件读取文本,但该软件无法读取=、分数等...

谢谢!

答案1

一个非常简短的例子

\documentclass{book}

\usepackage{amsmath}

\renewcommand{\frac}[2]{#1\; \text{over}\; #2}%


\begin{document}
\begin{math}
  \frac{1}{3}
\end{math}


\end{document}

但是我宁愿使用新命令而不是覆盖\frac,因此我提供了另一个版本:

\documentclass{book}


\newcommand*{\readoutfrac}[2]{#1\; \textbf{over}\; #2}%

%%%%%
% Uncomment this if you want to have \frac behave like \literalfrac
% \renewcommand*{\frac}[2]{\readoutfrac{#1}{#2}}%


\begin{document}
\begin{math}
 \frac{1}{3} =  \readoutfrac{1}{3}
\end{math}

\end{document}

请随意删除\textbf{},我只是为了让单词超过吸引眼球 ;-)

在此处输入图片描述

另一个版本

我介绍了某种开关,可以随时在传统输出\frac和其文字版本之间切换。

\documentclass{book}
\usepackage{etoolbox}

\newbool{UseForBlindVersion}
\setbool{UseForBlindVersion}{false}

\newcommand*{\EnableForBlindVersion}{%
\setbool{UseForBlindVersion}{true}
}%

\newcommand*{\DisableForBlindVersion}{%
\setbool{UseForBlindVersion}{false}
}%

\newcommand*{\readoutfrac}[2]{#1\; \textbf{over}\; #2}%


\let\LaTeXStandardFracCmd\frac%
\renewcommand{\frac}[2]{%
\ifboolexpr{bool{UseForBlindVersion}}{%
\readoutfrac{#1}{#2}%
}{%
\LaTeXStandardFracCmd{#1}{#2}%
}%
}%

\begin{document}
\DisableForBlindVersion%  Normal \frac
\[
 \frac{2}{6} =  \frac{1}{3}
\]
\EnableForBlindVersion%  Literal \frac

However, 
\[
 \frac{1}{4} \neq  \frac{1}{3},
\]

and on the other hand

\DisableForBlindVersion
\[
 \frac{1}{12} =   \frac{1}{3} - \frac{1}{4}
\]
\end{document}

在此处输入图片描述

带括号的另一个版本

我添加了一个代码,它会自动将括号添加到分数中(除非通过标志命令关闭或作为选项\frac代码没有分析括号在数学上是否必要!

\documentclass{book}
\usepackage{etoolbox}
\usepackage{amsmath}
\usepackage{xkeyval}


% Some helper commands

\newrobustcmd{\ProvideBool}[2][true]{%
\providebool{#2}%
\setbool{#2}{#1}
\long\csgdef{Enable#2}{%
\booltrue{#2}%
}%
\long\csgdef{Disable#2}{%
\boolfalse{#2}%
}%
}%

\makeatletter
\newrobustcmd{\GenerateBooleanKey}[5][false]{%   This solution is from Joseph Wright, 
% https://tex.stackexchange.com/questions/152012/generate-xkeyval-boolean-keys-on-the-fly
  \begingroup
  \edef\x{\endgroup
    \noexpand\define@boolkey{#2}{#3}[#1]{%
      \expandafter\noexpand\csname ifKV@#2@#3\endcsname%
        \noexpand #4% Do something if true
      \noexpand\else%
        \noexpand #5%   % Do something different if false
      \noexpand\fi%
    }% End of  \define@boolkey
  }% End of defintion of \x
  \x
}% End of \providecommand


\newrobustcmd{\GenerateEnableDisableBooleanKey}[3][false]{%
\ProvideBool{#3}%
\GenerateBooleanKey[#1]{#2}{#3}{%
\csname Enable#3\endcsname%
}{\csname Disable#3\endcsname}%
}%

\makeatother

\ProvideBool{ForBlindVersion}




\GenerateEnableDisableBooleanKey[false]{ReadOutExpressions}{AutomaticParentheses}

\GenerateEnableDisableBooleanKey[false]{ReadOutExpressions}{AutomaticNominatorParentheses}
\GenerateEnableDisableBooleanKey[false]{ReadOutExpressions}{AutomaticDenominatorParentheses}


\EnableForBlindVersion


\ifboolexpr{bool{ForBlindVersion}}{%
\presetkeys{ReadOutExpressions}{AutomaticNominatorParentheses=true,
                                AutomaticDenominatorParentheses=true,
                                AutomaticParentheses=true}{}%

}{
\presetkeys{ReadOutExpressions}{AutomaticNominatorParentheses=false,
                                AutomaticDenominatorParentheses=false,
                                AutomaticParentheses=false}{}%
}%

% Readout commands... (well, readout in the sense of read out by other software )
\newcommand*{\readoutfrac}[2]{#1\; \textbf{over}\; #2}%

\newcommand*{\readoutneq}{\;\textbf{is not equal to}\;}%



\let\LaTeXStandardFracCmd\frac%

\renewcommand{\frac}[3][]{%
\setkeys{ReadOutExpressions}{#1}
\ifboolexpr{bool{AutomaticParentheses}}{%
\ifboolexpr{not(bool{AutomaticDenominatorParentheses})}{%
\DisableAutomaticDenominatorParentheses}{\EnableAutomaticDenominatorParentheses}%
\ifboolexpr{not(bool{AutomaticNominatorParentheses})}{%
\DisableAutomaticNominatorParentheses}{\EnableAutomaticNominatorParentheses}%
}{%
}%
\ifboolexpr{bool{AutomaticNominatorParentheses}}{
\edef\Nominator{\left({#2}\right)}%
}{
\edef\Nominator{#2}%
}
\ifboolexpr{bool{AutomaticDenominatorParentheses}}{
\edef\Denominator{\left({#3}\right)}%
}{
\edef\Denominator{#3}%
}
%
\ifboolexpr{bool{ForBlindVersion}}{%
\readoutfrac{\Nominator}{\Denominator}%
}{%
\LaTeXStandardFracCmd{\Nominator}{\Denominator}%
}%
\DisableAutomaticParentheses%
}%




\let\LaTeXStandardNeqCmd\neq%
\renewcommand{\neq}{%
\ifboolexpr{bool{ForBlindVersion}}{%
\readoutneq%
}{%
\LaTeXStandardNeqCmd%
}%
}%





\begin{document}
\DisableForBlindVersion%
\[
 \frac{2}{6} =  \frac{1}{3}
\]
\EnableForBlindVersion%


However, 
\[
 \frac{1}{4} \neq  \frac{1}{3},
\]


\EnableForBlindVersion
However, 
\[
 \frac[AutomaticDenominatorParentheses=false]{1+x}{3} \neq  1 + \frac{x}{3},
\]


and on the other hand


\DisableForBlindVersion
\[
 \frac{1}{12} =   \frac{1}{3} - \frac{1}{4}
\]





\end{document}

我使用了我以前的问题中的一些代码,可以在这里找到:动态生成 xkeyval 布尔键,该问题的解决方案来自J. Wright。

在此处输入图片描述

请注意,这只是一个提议,而不是最终可行的软件包构想——我完全不知道阅读软件如何才能达到预期的效果。可以把它想象成一个游乐场、一个沙箱……

相关内容