3

I am overwriting \frac code and making it longer and thicker. I am successful so far. Thick frac is better for printing, but it seems sharp on the edges. I want to make its edges rounded. Is there anyone who knows how to do that. Thanks for reading and responding.

My code:

\documentclass[9pt]{article}
\usepackage{extsizes}
\usepackage{amsmath}
\usepackage{graphicx}

% \frac overwrite
\newcommand{\thickfrac}[2]{\genfrac{}{}{0.8pt}{0}{#1}{#2}}

\newcommand\bigfrac[3][2.0pt]{%
{\thickfrac{\hspace{#1}#2\hspace{#1}}{\hspace{#1}#3\hspace{#1}}}}


\let\oldfrac\frac
\let\frac\bigfrac
% \frac overwritten

\begin{document}
\thispagestyle{empty}
$$
\frac{\frac{a}{b}}{c} - \frac{d}{\frac{e}{1+\frac{f}{g} } } + \frac{h}{i}
$$ 

\end{document}

Output : sharp edge frac

  • 1
    Related: \mathrule at tex.stackexchange.com/questions/161297/… – Steven B. Segletes Feb 4 '15 at 13:35
  • I've tried the solution in 161297. It requires packages that I cannot use (don't ask why :) ) and I found it too complicated for further maintenance. I will wait my chances for a simpler/light-weight answer that I can compile with xelatex. – ahmetbayirli Feb 4 '15 at 14:37
  • Your assumption is wrong. Thicker fraction lines add nothing to clarity and ruin the typesetting. – egreg Feb 4 '15 at 20:42
  • @egreg Sir, I agree with you. I expressed myself wrong. My projects final product is first converted into a *.png file and then scaled before print. So lines seem thinner then actual size. You've helped me before about making +-= bold. thank you for that. I made \frac thicker so it seems normal at final print. – ahmetbayirli Feb 5 '15 at 11:09
8

While the OP has indicated that he cannot accept this answer because of the packages it uses, I will present it nonetheless to show a practical application of my roundrule.sty package. It is not found on CTAN, but only at the bottom of this answer: Is there such a thing as a `\mathrule`? (rounded endcaps).

Using that package and this MWE below, I first give the OP's original answer (\thickfracA). I then give my answer that only works in \displaystyle, known as \thickfracB. Finally, I give an answer that works across math styles, as \thickfracC.

\documentclass[9pt]{article}
\usepackage{extsizes}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{stackengine,scalerel,roundrule}
\stackMath
% \frac overwrite
\newcommand{\thickfracA}[2]{\genfrac{}{}{0.8pt}{0}{#1}{#2}}
% DISPLAYSTYLE ONLY
\newcommand\thickfracB[2]{%
  \setstackgap{S}{2.5pt}%
  \setbox0=\hbox{\stackon{#1}{#2}}%
  \mkern2.4mu%
  \raisebox{\dimexpr.5\ht\strutbox-.5\dp\strutbox}{\stackunder{%
    \stackon{\roundrule[-.4pt]{\wd0}{.8pt}}{#1}%
  }{%
    #2%
  }}%
  \mkern2.4mu%
}
% ANY MATHSTYLE
\newcommand\thickfracC[2]{\ThisStyle{%
  \setbox1=\hbox{$\SavedStyle($}%
  \setstackgap{S}{2.5\LMpt}%
  \setbox0=\hbox{\stackon{\SavedStyle#1}{\SavedStyle#2}}%
  \mkern2.4mu%
  \raisebox{\dimexpr.5\ht1-.5\dp1}{\stackunder{%
    \stackon{\roundrule[-.4\LMpt]{\wd0}{.8\LMpt}}{\SavedStyle#1}%
  }{%
    \SavedStyle#2%
  }}%
  \mkern2.4mu%
}}

\newcommand\bigfrac[3][2.0pt]{%
{\thickfrac{\hspace{#1}#2\hspace{#1}}{\hspace{#1}#3\hspace{#1}}}}

\let\oldfrac\frac
\let\frac\bigfrac
% \frac overwritten
\begin{document}
\centering
ORIGINAL\let\thickfrac\thickfracA
\thispagestyle{empty}
\[
x =\frac{\frac{a}{b}}{c} - \frac{d}{\frac{e}{1+\frac{f}{g} } } + \frac{h}{i}
\]
displaystyle ONLY\let\thickfrac\thickfracB
\[
x =\frac{\frac{a}{b}}{c} - \frac{d}{\frac{e}{1+\frac{f}{g} } } + \frac{h}{i}
\]
ANY MATHSTYLE\let\thickfrac\thickfracC
\[
\scriptstyle
x =\frac{\frac{a}{b}}{c} - \frac{d}{\frac{e}{1+\frac{f}{g} } } + \frac{h}{i}
\]
\end{document}

enter image description here

Here is the zoom on the \displaystyle answer.

enter image description here

  • It would be nice if the distances and dimensions where the same, that is, taken from \fontdimens. – Manuel Feb 4 '15 at 15:10
  • @Manuel I wish I knew how to do that. :^) – Steven B. Segletes Feb 4 '15 at 15:11
  • Neither do I. Anyway, wouldn't it be easier if you actually typeset the \frac but overlap the rounded rule? That seems easy and would definitely give the same output as with \frac. – Manuel Feb 4 '15 at 15:14
  • 1
    @Manuel I had momentarily considered that approach, but forgot about it. The one issue I would see with it, is the rule would always be 1 rule thickness wider than that produced by \frac, rather than taking up the same width. But maybe it's worth a try. – Steven B. Segletes Feb 4 '15 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.