# I need to write extra version for blind people without braille

I am writing a small math script and I also need to make version for blind people, but without braille. For example \frac{1}{2} shouldn't be literal fraction, but it should be 1 over 2. Can I override \frac command to write it the way I want it? If yes, how to do it? I was told that they are using a software to read them text, but that software can't read =, fractions, etc...

Thanks!

-
The implicit parentheses of \frac, \sqrt and others might be a problem. If you just replace as indicated, \frac{1+x}{3} and 1 + \frac{1}{3} will turn out the same. It would be simple to always insert () but probably awkward to read. To analyze the arguments to see if parens are needed sounds complicated. Have you spoken to the blind readers about what they expect in such cases? –  pst Apr 15 '14 at 10:05
@pst: You are right, I did have that in mind, but as you stated, in order to catch extended (de)nominators will be really complicated. –  Christian Hupfer Apr 15 '14 at 11:15
@pst: I thought about your 'objection' concerning the parentheses. How would one read \frac{1+x}{3}, for example in a mathematics lesson. Perhaps 'left bracket 1 plus x right bracket over 3'. Adding '()' might be tedious but would clarify a fraction. I admit, however, that analyzing on LaTeX level will be very difficult –  Christian Hupfer Apr 17 '14 at 14:34
I heard about this sort of thing from somewhere, and the reader (or presumably reading software) has to verbalize all parentheses, as well as noting whenever a letter is uppercase. So it sounds different from mathematics "read aloud" in another context. –  Charles Staats Apr 17 '14 at 14:58

A really short example

\documentclass{scrbook}

\usepackage{amsmath}

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

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

\end{document}


But I would rather use a new command instead overriding \frac, so I provide another version:

\documentclass{scrbook}

%%%%%
% Uncomment this if you want to have \frac behave like \literalfrac

\begin{document}
\begin{math}
\end{math}

\end{document}


Please remove the \textbf{} at will, I just introduced it to make the word over as an eye-catcher ;-)

Another Version

I introduced some kind of a switch, which can be used any time to switch between traditional output of \frac and its literal version.

\documentclass{scrbook}
\usepackage{etoolbox}

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

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

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

\let\LaTeXStandardFracCmd\frac%
\renewcommand{\frac}[2]{%
\ifboolexpr{bool{UseForBlindVersion}}{%
}{%
\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}


EVEN ANOTHER VERSION WITH PARENTHESIS

I added a code which automatically adds parenthesis to the fraction (unless switched off by flag command or as an option to \frac command. The code does not analyze whether the parentheses is mathematically necessary or not!

\documentclass{scrbook}
\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,
% http://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}

\EnableForBlindVersion

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

}{
AutomaticDenominatorParentheses=false,
AutomaticParentheses=false}{}%
}%

\let\LaTeXStandardFracCmd\frac%

\renewcommand{\frac}[3][]{%
\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}}{%
}{%
\LaTeXStandardFracCmd{\Nominator}{\Denominator}%
}%
\DisableAutomaticParentheses%
}%

\let\LaTeXStandardNeqCmd\neq%
\renewcommand{\neq}{%
\ifboolexpr{bool{ForBlindVersion}}{%
}{%
\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}


I used some code from a former question of mine, which can be found here: Generate xkeyval boolean keys 'on the fly', the solution to that question came from J. Wright.

Note, this is just a proposal, not a finally working package idea -- I have no idea how a reading software will do as expected at all. Think of it as a playground, a sandbox...

-
Thanks. It's just what I wanted. I also thought of writing a new command but then I would need two versions of a same file. This way I can only \input modified commands. Is there a reason you suggested writing a new command? –  Vizualni Apr 15 '14 at 8:03
Using a well-known command such as \frac making it behave 'completely' different to common use can cause confusion. I believe, it is ok, when you typeset your whole document this way. By the way: Very good question!! –  Christian Hupfer Apr 15 '14 at 8:06