1

I have the following code:

$$
\begin{Large}
\textbf{Volume = } \bm{{\dfrac{nhs^2}{12}}\Bigl(\!\csc\bigl({\tfrac{\pi}{n}}\bigr) + 2\cot\bigl({\tfrac{\pi}{n}}\bigr)\!\Bigr)}
\end{Large}
$$

Which generates:

enter image description here

Which is what I want except for the excessive vertical space between nh$s^2$ and the fraction bar. Does anyone know how to reduce this? Using \frac instead of \dfrac didn't help and I don't want to shrink the whole fraction by using \tfrac.

4
  • Is nhs the name of a variable, or does it denote the product of the variables n, h, and s? Please advise.
    – Mico
    Commented Feb 11 at 13:57
  • 1
    you should not use $$ in latex and you definitely should never use a size command such as \Large in math mode (LaTeX will have warned about this). Commented Feb 11 at 14:53
  • @DavidCarlisle - Belated congratulations on passing the 750k rep point mark!
    – Mico
    Commented Feb 11 at 18:46
  • Please enlighten us to why \Large and \bm would appear to be important to you for the formula at hand.
    – Mico
    Commented Feb 12 at 3:34

2 Answers 2

3

I don't think you want to move the numerator nearer to the fraction line: consider

\frac{nhs}{10}+\frac{g}{2}

that I'll represent in two ways, the one you're asking for and the standard one

enter image description here

Do you see the problem? The height of the numerators are inconsistent. Having a single fraction in the formula is irrelevant, in my opinion.

You can achieve the reduced spacing with

\frac{\raisebox{-0.4ex}{$\displaystyle nhs^2$}}{12}

if you really want to, but I'd not do it. And I'd probably follow Mico's suggestion to do

\frac{1}{12}nhs^2

Second problem with your code. You want to emphasize your equation, but is there any reason to use \Large size and boldface? Your equation is already displayed, this is sufficient to emphasize its importance. Maybe (but I'd not do it) boldface, but definitely not \Large. Anyway, none of the methods Mico suggest is good, I'm afraid.

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}% for context

\newenvironment{vardisplay}[1]{%
  % #1 contains the settings to apply
  $$% start a display
  \hspace{0pt}\begin{minipage}{\displaywidth}#1\noindent\ignorespaces
}{%
  \end{minipage}\hspace{1000pt minus 1fill}$$\ignorespacesafterend
}

\begin{document}

\lipsum[1][1-5]
\begin{equation*}
\mathrm{Volume} =
  \frac{nhs^2}{12}
  \bigl(\csc\bigl(\tfrac{\pi}{n}\bigr) + 2\cot\bigl(\tfrac{\pi}{n}\bigr)\bigr)
\end{equation*}
\lipsum[2][1-5]
\begin{vardisplay}{\boldmath}
\begin{equation*}
\mathrm{Volume} =
  \frac{nhs^2}{12}
  \bigl(\csc\bigl(\tfrac{\pi}{n}\bigr) + 2\cot\bigl(\tfrac{\pi}{n}\bigr)\bigr)
\end{equation*}
\end{vardisplay}
\lipsum[3][1-5]
\begin{vardisplay}{\boldmath\Large}
\begin{equation*}
\mathrm{Volume} =
  \frac{nhs^2}{12}
  \bigl(\csc\bigl(\tfrac{\pi}{n}\bigr) + 2\cot\bigl(\tfrac{\pi}{n}\bigr)\bigr)
\end{equation*}
\end{vardisplay}
\lipsum[4][1-5]

\end{document}

enter image description here

Seeing the formula in context and compared to the other realizations should convince you that the first one is better.

The same but with

\frac{1}{12}nhs^2

enter image description here

2
  • The \raisebox worked - thank you!
    – Nate
    Commented Feb 12 at 7:04
  • @Nate The main purpose of my answer was to tell you not to use it. 😊
    – egreg
    Commented Feb 12 at 7:56
2

The following screenshot features three equations: (i) the OP's original version; (ii) a version that cleans up the OP's code (e.g., by getting rid of a number of unneeded pairs of curly braces) and uses \tfrac{1}{12} nhs^2 in place of \dfrac{nhs^2}{12} to achieve the OP's stated formatting objective; and (iii) a version of (ii) that employs normal-weight math, as I don't understand the purpose of bold-facing the entire formula. "For when everything is bold, nothing is bold..."

Aside: Please don't use $$ in a LaTeX document. Instead, use \[ and \] to initiate and terminate an unnumbered displayed math group. For a longer discussion of this issue, please see the posting Why is \[ ... \] preferable to $$ ... $$? Finally, do note that \Large is a text-mode command; its use inside math mode can have unpredictable results.

enter image description here

\documentclass{article}
\usepackage{amsmath,bm}
\begin{document}

$$
\begin{Large}
\textbf{Volume = } \bm{{\dfrac{nhs^2}{12}}\Bigl(\!\csc\bigl({\tfrac{\pi}{n}}\bigr) + 2\cot\bigl({\tfrac{\pi}{n}}\bigr)\!\Bigr)}
\end{Large}
$$

\begingroup % localize scope of next two instructions
\Large
\boldmath % <-- use \boldmath *before* entering math
\[
\textbf{Volume} = 
  \tfrac{1}{12}\, nhs^2
  \bigl( 
         \csc\tfrac{\pi}{n} 
      + 2\cot\tfrac{\pi}{n}
  \bigr) 
\]
\endgroup

\begingroup
\Large
\[
\mathrm{Volume} = 
  \tfrac{1}{12}\, nhs^2
  \bigl(
         \csc\tfrac{\pi}{n} 
      + 2\cot\tfrac{\pi}{n}
  \bigr)
\]
\endgroup

\end{document}

You must log in to answer this question.

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