81

When I take the pth root, the bottom of the p comes very close to the \sqrt symbol. In the New Century Schoolbook font (which I am using), the p actually intersects the \sqrt symbol, which looks even more terrible. Is there a clean way to fix this?

\documentclass{article}
\usepackage{fouriernc} % use the New Century Schoolbook font
\begin{document}
When I write $a^{(1/p)}$ as $\sqrt[p]{a}$, the bottom of the $p$
touches the top of the root symbol, which looks ugly.
Even when the root symbol is larger, such as with
$\sqrt[p]{\frac{1}{n}}$, it still looks bad
(since the tail of the p almost hits that line).
\end{document}

Ugly-looking <code>\sqrt[p]{a}</code>

jamaicanworm
  • 29,114

5 Answers5

58

The amsmath package provides commands to tweak the position of the p, this example is from the amsmath documentation:

\sqrt[\leftroot{-2}\uproot{2}\beta]{k}
David Carlisle
  • 757,742
  • 1
    Thanks! Is it wise to / how can I (re-)define the \sqrt command to use these preferences automatically? – jamaicanworm Mar 22 '12 at 23:55
  • 2
    @jamaicanworm you can redfine \sqrt using the method illustrated in best-practices-for-spacing-regarding-fractions-and-roots/ and the linked question within – cmhughes Mar 22 '12 at 23:59
  • 1
    This seems a bit simpler: \let\oldsqrt\sqrt \def\sqrt[#1]{\oldsqrt[\leftroot{-3}\uproot{3}#1]} Are there any disadvantages of this solution compared to the LetLtxMacro one you linked to? Also, in this solution, there is a slight problem: now, if I write sqrt{a} (without the optional [] argument), it gives an error. – jamaicanworm Mar 23 '12 at 00:05
  • 4
    don't use \def to define commands with optional arguments, use \renewcommand\sqrt[2][2]{... so the optional argument defaults to 2. – David Carlisle Mar 23 '12 at 07:13
  • 2
    @DavidCarlisle: As I told jamaicanworm already, it's always nice to have a picture of the result in an answer so that users can evaluate and compare answers without having to compile each one of them. Of course, you, too, will get more upvotes, which are the sole reason we're all here :) – doncherry Mar 23 '12 at 10:07
30

In line with the suggestion @DavidCarlisle gave in his answer, I also recommend that you load the amsmath package and experiment a bit with the \leftroot and \uproot options to the \sqrt macro.

In fact, since your root symbol, p, has a longer lower-left spur and a smaller overall height than the \beta symbol that's used in the example code of the amsmath package's user guide does, you may want to use 3 rather than 2 as the argument of both \leftroot and \uproot in order to get a more balanced looking expression.

enter image description here

\documentclass{article}
\usepackage{fouriernc} % New Century Schoolbook text and math font clones
\usepackage{amsmath}

\begin{document} $\begin{array}{cc} \sqrt[p]{a} & \sqrt[\leftroot{-3}\uproot{3}p]{a} \[2ex] \sqrt[p]{\frac{1}{n}} & \sqrt[\leftroot{-3}\uproot{3}p]{\frac{1}{n}} \end{array}$ \end{document}

Mico
  • 506,678
24

Quick and dirty answer: use superscript p in the pth root symbol, i.e. \sqrt[^p]{x}. Not elegant, but mostly good enough. This is also fast and easy if you're using something like LyX. For example: enter image description here

Kurt Cogswell
  • 241
  • 2
  • 2
10

This should be more of a comment (in reply to the OP's comment for David's answer) than answer (I can not break lines in comment).

You can define a new command \mysqrt instead of trying to meddle with the original \sqrt command.

\newcommand*{\mysqrt}[4]{\sqrt[\leftroot{#1}\uproot{#2}#3]{#4}}
\[\mysqrt{-2}{2}{\beta}{k}\]
\[\mysqrt{-3}{3}{\beta}{k}\]
\[\mysqrt{-2}{6}{\beta}{\frac{k}{h}}\]

Advantage: You can change the first two values values on the go and your old \sqrt works without the option [].

enter image description here

  • Does \mysqrt work even if you omit one of those values (e.g., if you give it 1, 2, or 3 arguments instead of 4)? Unfortunately, I already have a huge document full of \sqrts, and I don't want to replace all of them. But thanks for the help! – jamaicanworm Mar 23 '12 at 00:27
  • 1
    In this case I would make the first two parameters to \mysqrt optional and default to something that works for most cases, but can be tweaked if so desired. – Peter Grill Mar 23 '12 at 00:29
  • 1
    @jamaicanworm If you do not give values TeX will complain of a missing number that will be treated as zero. Hence you can put zero yourself to avoid that complain. and yes it works except that complaint. –  Mar 23 '12 at 00:32
  • @PeterGrill How do you make a parameter optional? – jamaicanworm Mar 23 '12 at 00:33
  • 1
    @jamaicanworm: Since there is more than one parameter that should be optional, I would use the xparse package and the solutions described at LaTeX command with optional arguments – Peter Grill Mar 23 '12 at 00:39
  • @Peter Grill I tried using the xparse package, but for some reason this is giving 82 errors: \let\oldsqrt\sqrt \def\sqrt[#1]{\oldsqrt[\leftroot{-3}\uproot{3}]\IfNoValueTF{#1}{}{#1}} – jamaicanworm Mar 23 '12 at 00:50
  • 1
    @jamaicanworm: That is not how to use xparse. Using \NewDocumentCommand{\mysqrt}{O{-2} O{2} O{} m}{...} will make #1 default to -2, #2 default to 2, and #3 default to {}. Hope that helps -- if not, this should really be a separate question as it might be useful to others as well. – Peter Grill Mar 23 '12 at 00:56
  • 1
    Version discussed in the comments here is provided at Optional arguments in \def. – Peter Grill Mar 23 '12 at 01:36
3

I tried Unicode math Schola font (it is an equivalent to the New Century) and it seems that there is no problem when classical \root macro is used. I did the test with OpTeX but you can try it with different macro if you want.

\fontfam[schola]

test: $\root p\of a$

\bye

root of p

wipet
  • 74,238