13

My problem is that I am about to write a longer mathematical text, and it will be filled with integrals. Integrals tend to be filled with pesky fractions, square roots and what not.

Personally I feel like LaTeX is spacing things "wrongly" I prefer to have more space in my fractions, and a tad more space after the square roots. Look at the comparison below. The difference is small, but noticable.

How it normally looks

enter image description here

How I prefer it to look

enter image description here

My question is that, I think doing these small fixes manually is bad. So my question is

Should I avoid doing it? I mean is it "wrong"?

And if not, is there a more automatic solution to this?

(Right now I am merely putting in some space after the roots. like \, )

Here is a smaller MWE, I think the right side looks better than the left.

\documentclass[10pt,a4paper]{minimal}
\usepackage{mathtools}

\begin{document}

\begin{align*}
\int \frac{1+x^2}{1+x^4} \mathrm{d}x \qquad & \text{versus} \qquad \int \frac{\,1+x^2\,}{\,1+x^4\,}\, \mathrm{d}x\\
\int_1^\infty \frac{\mathrm{d}x}{x\sqrt{-1+\sqrt[n]{x}}} \qquad  & \text{versus} \qquad \int_1^\infty \frac{\mathrm{d}x}{\,x\sqrt{-1+\sqrt[n]{x}\,}\,} 
\end{align*}

\end{document}
David Carlisle
  • 757,742
N3buchadnezzar
  • 11,348
  • 7
  • 55
  • 114

2 Answers2

13

You could renew the \sqrt command to put the space in automatically.

Renewing the \sqrt command is a little tricky because it takes an optional argument. Luckily it has been demonstrated in

"Closed" (square) root symbol

Here's a screenshot of the result

enter image description here

In the MWE below, you'll see that I have \renewcommanded the \sqrt command to be itself, but with a space immediately following it using \, The subtleties involved are described in detail in the linked post.

\documentclass{article}

\usepackage{letltxmacro}
\LetLtxMacro{\oldsqrt}{\sqrt}
\renewcommand{\sqrt}[2][]{\oldsqrt[#1]{#2}\,}


\begin{document}
OLD
\[
   \int\oldsqrt{x}\mathrm{d}x
\]  

NEW
\[
   \int\sqrt{x}\mathrm{d}x
\]  
\end{document}

I think that in the context of your particular document, you might want the option to define a separate 'spaced square root symbol' so that you don't affect all of the \sqrt. You could achieve this using

\newcommand{\ssqrt}[2][]{\oldsqrt[#1]{#2}\,}

and, of course, you can name it anything you like- I used \ssqrt to stand for 'spaced square root'.

cmhughes
  • 100,947
6

The issue of inserting a bit of space every time the "differential operator" d is used is best addressed by defining a new operator, say \dee, that leaves the required amount of whitespace before the operator and typesets the operator in upright ("roman") font. For instance, you could define

\newcommand{\dee}{\operatorname{d}\!}

in the preamble, and then use it from now on every time you are referring to a d that's a differential.

If you have no need for the Icelandic-d that's generated by LaTeX with the command \d, you could alternatively define, i.e., if you'd like to type \d to generate the differential operator "d", you could use the following definition:

\renewcommand{\d}{\operatorname{d}\!}

As @JimHefferon has pointed out in a comment, a slight spacing adjustment is required for typesetting inline math expressions such as dy/dx (with both ds set in upright mode). For this particular term, one would write (using the second definition above):

$\d y/\!\d x$

enter image description here

where the instruction \! instructs TeX to insert a "negative thin space," thereby undoing the "positive thin space" that's inserted by the operator \d.

Mico
  • 506,678
  • 2
    Doesn't this look funny when you type $\dee y/\dee x$? – Jim Hefferon Mar 15 '12 at 13:06
  • Personaly In my documents I simply type \dy and \dx, these are defined as \mathrm{d}x \mathhop{}\ \! =) – N3buchadnezzar Mar 15 '12 at 16:47
  • I'm sorry; so you have \def\dx{\mathrm{d}x \mathhop{}\ !} is that right? In particular, in the fraction $\dy/\dx$ you have the d's in mathrm but the x and y in italics? When I tried it in the past, it looked odd to me. (But my taste is not very well-developed, I admit.) – Jim Hefferon Mar 15 '12 at 18:19
  • @JimHefferon: I've gone ahead and rewritten my answer to make use of the command \operatorname; the advantage of doing so, relative to the "brute force" definition, viz., \renewcommand{\d}{\,\mathrm{d}}, is that one avoids unnecessary whitespace if the operator is used at the beginning of a line (and at the start of some math material). – Mico Mar 15 '12 at 18:25
  • @JimHefferon : A quick note on style. It is not as much as if it looks good, but whetere it is "correct". Variables are in cursive, operators are not. ^^ – N3buchadnezzar Mar 16 '12 at 18:55
  • 1
    For differential operators, derivatives, and so on, you might want to consider the commath package. I used to have a whole set of custom commands (like \dy{y}{x} for dy/dx, \pa{f}{x} for partial derivatives), but now I use this instead, which I find much cleaner. – alexwlchan May 31 '12 at 15:44