4

I've been looking around and found that this question has been asked at least a couple of times, but the solutions are been correct work around.

Let's say that I have a formula with a piece like:

e^{\dfrac {h A_s}{\rho V c_{p}}t}

and for some dumb reason, I'd like to force the argument of the exponential to be shown as a \dfrac... worst!!! I refuse to use the \exp command to denote the exponential, say I just want to define a command \myexp which 'measure' the size of the exponential argument and resize the letter e according to the size of the argument.

Is that even possible? How could be done?

Thank you!

3
  • 1
    If you want a badly typeset document… Otherwise write $\exp(thA_s/\rho Vc_p)$
    – egreg
    Commented Apr 23, 2014 at 20:23
  • hahahaha... Sure, I know, but the thing is... If I were a hard-head guy , who insists in doing so. How could I do it? (if possible) XD
    – Dox
    Commented Apr 23, 2014 at 20:25
  • 1
    I surely won't even try. ;-)
    – egreg
    Commented Apr 23, 2014 at 20:27

2 Answers 2

7

I should probably not be surprised to get negative points for this answer.

Here's something you could do, but I think it results in a very ugly output. Granted, this is a brute-force approach and could probably be a bit more prettified. But even then, I think, it would still be ugly.

\documentclass{article}
\usepackage{booktabs}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}

\newsavebox\myuglybox
\def\mye#1{%%
  \savebox{\myuglybox}{$#1$}%%
  \resizebox{!}{\ht\myuglybox}{$\mathrm{e}$}^{\usebox{\myuglybox}}}

\pagestyle{empty}
\begin{document}

\begin{tabular}{ccc}
  Scaled (Ick!)                                & Unscaled (Ick!)                              & Preferred \\\midrule
$\dfrac{1}{\sqrt{2\pi}}\mye{-\dfrac{1}{2}x^2}$ & $\dfrac{1}{\sqrt{2\pi}}e^{-\dfrac{1}{2}x^2}$ & $\dfrac{1}{\sqrt{2\pi}}\exp\left(-\dfrac{1}{2}x^2\right)$
\end{tabular}

\vspace{3ex}

Monster content

$\mye{\dfrac{1}{\sqrt{2\pi}}\mye{-\dfrac{1}{2}x^2}}$

\end{document}

enter image description here

If this is something that works for you, I'll leave the prettifying to you.

2
  • @egreg, surely from you I would have expected demerits. ;)
    – A.Ellett
    Commented Apr 23, 2014 at 22:09
  • @A.Ellett Great! I leant how to use \savebox and \resizebox... thank you!
    – Dox
    Commented Apr 24, 2014 at 0:14
4

Here, I make the e 66.6% of the height+depth of the exponent, and raise the exponent by its depth + .45height above the baseline. I compare this formulation on the left side to the traditional $e^{}$ formulation without \dfrac on the right side.

EDITED to add strut to argument.

\documentclass{article}
\usepackage{scalerel}
\usepackage{amsmath}
\newlength\tempdimA
\newlength\tempdimB
\def\myexp#1{\setbox0=\hbox{$\strut#1$}\tempdimA=\dimexpr\ht0+\dp0\relax%
  \tempdimB=\dimexpr.45\ht0+\dp0\relax%
  \scaleto{e}{.666\tempdimA}% THE e WILL BE .666 THE HEIGHT+DEPTH OF THE EXPONENT
  \raisebox{\tempdimB}{\box0}}
\parskip 1em
\begin{document}
\renewcommand\arraystretch{2}
\begin{tabular}{cc}
{\ttfamily\textbackslash myexp} & \verb|e^{}| \\
$\myexp{\dfrac {h A_s}{\rho V c_{p}}t}$ & $e^{\frac {h A_s}{\rho V c_{p}}t}$\\
$\myexp{-\dfrac{1}{2}x^2}$ & $e^{-\frac{1}{2}x^2}$\\
$\myexp{\sqrt{b^2-4Ac}}$ & $e^{\sqrt{b^2-4Ac}}$\\
$\myexp{Ax}$ & $e^{Ax}$\\
$\myexp{x}$ & $e^{x}$
\end{tabular}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .