Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
4  
The pictures can still be simplified in order to focus on the target. –  In PSTricks we trust Mar 15 '12 at 1:13
    
Could you drop the source somewhere? It would help me understand the difference. –  Jim Hefferon Mar 15 '12 at 13:09
1  
I can't perceive of any difference in the fractions in for instance #1 or #10 –  Matthew Leingang Mar 15 '12 at 13:12
    
Yes, and there is a mistake in the copy of #11. The source would help. –  Jim Hefferon Mar 15 '12 at 13:29

2 Answers 2

up vote 12 down vote accepted

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'.

share|improve this answer
    
Would it perhaps be better to use \mathhop so one would always get propper spacing ? =) –  N3buchadnezzar Mar 15 '12 at 1:20
    
@N3buchadnezzar that should be taken care of via the \LetLtxMacro command- it's just the old sqrt but with a bit of space after it :) –  cmhughes Mar 15 '12 at 1:28
    
@N3buchadnezzar glad it helped- good luck with your project :) –  cmhughes Mar 15 '12 at 16:27

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.

share|improve this answer
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
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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