[Tex/LaTex] Small in-text fractions


I'm writing things like 2/3 or 1/4 in my text and I'd like to make them appear as they do automatically in a processor like Word where they are slightly smaller and have the diagonal separation if that makes sense, instead of being placed on top of each other like it would appear in math mode.

Best Answer

I suggest you load the xfrac package and write $\sfrac{1}{2}$ to achieve your formatting objective by hand.

If you want to fully automate the process of typesetting all inline-math fractions with the \sfrac macro, the following, LuaLaTeX-based solution may be of interest to you.

enter image description here

% !TeX program = lualatex
\usepackage{xfrac}   % for \sfrac macro
\usepackage{luacode} % for "luacode" env.

%% Lua-side code
function make_nice_fracs(s)
  return (s:gsub ( "(%d%d*)/(%d%d*)", "\\sfrac{%1}{%2}" ))
%% LaTeX-side code
   luatexbase.add_to_callback ( "process_input_buffer", 
      make_nice_fracs, "make_nice_fracs" )}}

From $\sfrac{1}{22}$ to $\sfrac{33}{444}$. The quick brown dog\dots

From $1/22$ to $33/444$. The quick brown dog\dots

% Use whitespace before or after "/" suspends the Lua function
From $1 /22$ to $33/ 444$. The quick brown dog\dots
Related Question