Text FormattingIncorrect spacing between function name and following "("

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
zaradek
Posts: 22
Joined: Fri Jun 27, 2008 9:49 pm

Incorrect spacing between function name and following "("

Post by zaradek »

Why are there different horizontal spaces after the two log functions in the result of the following code?

Code: Select all

$\log\left(3\right)+\log(3)$
See attached the produced pdf.

Thanks,
Máté
Attachments
Example.pdf
(9.19 KiB) Downloaded 479 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
emime
Posts: 9
Joined: Wed Apr 15, 2009 10:43 pm

Incorrect spacing between function name and following "("

Post by emime »

The right use of a math function is by enclosing the arguments within {}. The following two log functions are equally spaced.

Code: Select all

$\log{\left(3\right)}+\log{(3)}$
By writing this

Code: Select all

$\log(3)$
you are not feeding the function with its argument...
Perhaps the following shows the difference between using \left( or (

Code: Select all

$a\left(3\right)\,a(3)$
\left(\right) has a different behavior than (). Normally, you need to use \left(\right) to adapt the parenthesis when using \frac or array and improve spacing.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Incorrect spacing between function name and following "("

Post by localghost »

emime wrote:The right use of a math function is by enclosing the arguments within {}. [...]
These commands have no arguments. Their only purpose is to typeset the according math function name in upright shape inside math environments.
zaradek wrote:Why are there different horizontal spaces after the two log functions in the result of the following code? [...]
At the moment I can't comprehend the problem. Perhaps the "Math mode" document gives some useful hints.


Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
zaradek
Posts: 22
Joined: Fri Jun 27, 2008 9:49 pm

Re: Incorrect spacing between function name and following "("

Post by zaradek »

Thanks for your answers. I believed the same, namely \log is just standing instead e.g. \mathrm{log}.

But I still don't know, how to avoid the huge space between \log and \left(.

See another example attached. The spacings are too big in the first line but they are correct in the second line. Do you know how to fix the first line?

Máté
Attachments
Example2.pdf
(20.81 KiB) Downloaded 451 times
Example2.tex
(334 Bytes) Downloaded 368 times
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Incorrect spacing between function name and following "("

Post by localghost »

zaradek wrote:[...] Do you know how to fix the first line? [...]
I'd say you've given the answer with the second line by adjusting the parenthesis manually. Despite the wrong explanation the method of emime could be a solution. A good example for eliminating horizontal space is the following code.

Code: Select all

$E=mc^2$

$E{=}mc^2$
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
zaradek
Posts: 22
Joined: Fri Jun 27, 2008 9:49 pm

Incorrect spacing between function name and following "("

Post by zaradek »

So, can we consider this issue as a bug in the latex?

On the other hand, what works in your example doesn't work in this case:

Code: Select all

$\log{\left(3\right)}$
It has the same huge space after the log.

Máté
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Incorrect spacing between function name and following "("

Post by localghost »

zaradek wrote:So, can we consider this issue as a bug in the latex? [...]
I don't think so. I consider the bigger space as the better one. But perhaps the document I mentioned earlier can give a hint. Search it for "delimiter spaces".
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
User avatar
emime
Posts: 9
Joined: Wed Apr 15, 2009 10:43 pm

Incorrect spacing between function name and following "("

Post by emime »

Sorry for the wrong explanation. I meant that generally is safer to use {} (typical case is ^ or \sqrt).

Code: Select all

\[a^23\neq a^{23}\]
I consider the extraspace the better one too, that's why I suppose {} gets the right behavior, even in common math functions.
Anyway, if you don't like extraspace use a negative hspace.

Code: Select all

\[\log\hspace{-3pt}{\left(k\right)\cdot x}\]
zaradek
Posts: 22
Joined: Fri Jun 27, 2008 9:49 pm

Re: Incorrect spacing between function name and following "("

Post by zaradek »

I see your opinion, but I'm on the contrary. :)
According to my experience in math typesetting from books and publications, there is never space between the function symbol/name and the opening bracket following that. But then it may not be so obvious as I believe...

By the way, simply the \! seems to produce the same space as in the case of using manual parenthesis.

Máté
Post Reply