2

In the book I'm writing there are some parts with math-mode spaces and math-mode inline spaces that are too excessive for me. The first and the second image that I am reporting are taken directly from the textbook that makes the idea of excessive spacing (see some annotates red arrows).

Real first image taken from my book

enter image description here

Real second image taken from my book

enter image description here

Here there is a compilable MWE that reproduces the similar problem. I was asking myself if the spacing is normal or if there is something that I should fix either in the text or in the preamble.

\documentclass[a4paper,12pt]{article}
\usepackage[top=2.5cm,bottom=2.2cm,
            left=3.2cm,right=1.5cm,headsep=10pt,
            a4paper]{geometry}  
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{newtxtext,newtxmath}
\showhyphens{matematica}
\begin{document}
\noindent Ovviamente deve essere $1-c^2>0$ e cioè $|c|<1$ perchè sia lecita la relazione \ldots. La costante arbitraria $c$ può avere segno qualsiasi; deve aversi cioè $\forall x\in ]a,b[, \,y'(x)=c/\sqrt{1-c^2}$ oppure $y'(x)=-c/\sqrt{1-c^2}$. Potrebbe essere $c=0$ compatibile solo con $y(a) = y(b)$, segmento parallelo all'asse $x$. Se $c\ne 0$, allora anche $c/\sqrt{1-c^2}\ne 0$, e dovendo $y'$ essere continua non può accadere che per certi $x\in ]a, b[$ valga il segno $+$ e per altri il segno $-$ (altrimenti $y'$ salterebbe senza assumere i valori intermedi fra $c/\sqrt{1-c^2}$ e $-c/\sqrt{1-c^2}$). Deve quindi valere $y'(x)=c/\sqrt{1-c^2}$ per ogni $x\in]a,b[$, oppure $y'(x)=-c/\sqrt{1-c^2}$ sempre per ogni $x\in]a,b[$: dato che $c$ è, come detto prima, costante di integrazione indeterminata, non si perde nulla a scrivere $y'(x)=c/\sqrt{1-c^2}$ qualunque sia $c$. Posto 
$m=c/\sqrt{1-c^2}\in \mathbb{R}$, ed essendo $c$ variabile in $]-1,1[$ allora $m=c/\sqrt{1-c^2}$ assumerà tutti i valori reali. La soluzione generale dell'equazione di Eulero è $y(x)=mx+k$; dovendo essere $y(a)=\alpha$ ed $y(b)=\beta$ si ricava $ma+k=\alpha$ ed $mb+k=\beta$, da cui $m=(\beta-\alpha)/(b-a)$ e $k=\alpha-a(\beta-\alpha)/(b-a)$. Ma ci si poteva fermare una volta scoperto che $y'$ deve essere costante: questo prova che le uniche soluzioni sono segmenti di rette come il percorso più breve, e ce n'è uno solo che passa per due punti dati $(a,\alpha)$ e $(b,\beta)$, come ben sappiamo. La funzione integranda non dipende esplicitamente da $x$ quindi il funzionale è del tipo
\[\mathscr{F}(y)=\int_{a}^{b}f(y,y')\,dx\]
In questo caso l'equazione di Eulero-Lagrange  
\[\frac d{dx} \frac{\partial f(y,y')}{\partial y'}-\frac{\partial f(y,y')}{\partial y}=0\]
Se poi $y$ è di classe $\mathcal{C}^2$ in $[a,b]$ diventa, dalla \eqref{elfd2}, per il teorema di derivazione delle funzioni composte,
\begin{equation}\label{edex}
f_{y}(y,y')-f_{y'y}(y,y')y'-f_{y'y'}(y,y')y''=0
\end{equation}
Moltiplicando la \eqref{edex} per $y'$, otteniamo l'equazione di Eulero-Lagrange è
\[\dfrac d{dx}(f-y'\,f_{y'})=0.\]
Infatti si ha
\[\begin{split}\dfrac d{dx}(f-y'\,f_{y'})&=f_y\,y'+f_{y'}\,y''-y''\,f_{y'}-(y')^2\,f_{yy'}-y'\,y''\,f_{y'y'}=\\
&=y'(f_y-y'\,f_{yy'}-y''f_{y'y'})=y'\cdot 0=0.\end{split}\]
\end{document}

The two outputs are:

enter image description here and enter image description here

For the users: see please the comments below.

Sebastiano
  • 54,118
  • @DavidCarlisle reading your link, it honestly looks like it's the same. But I currently do not know what action to take to have a good spacing even though I read the answer. Is there anything to insert in the preamble to have a correct spacing? – Sebastiano Jul 09 '19 at 20:07
  • follow the link to that duplicate and see Werner's answer you can set \thickmuskip (the space around = and < ) to smaller values as he shows there – David Carlisle Jul 09 '19 at 20:08
  • @DavidCarlisle So to have less spacing I have to insert each time \begingroup \setlength{\thickmuskip}{0mu} ........ \endgroup or \begingroup \setlength{\medmuskip}{0mu} ........ \endgroup or with \setlength{\thickmuskip}{0mu}...:-(? I was thinking of a macro or a package that would fix everything in one compilation for the whole document. – Sebastiano Jul 09 '19 at 20:15
  • Some of these spaces are explicit, entered with \,. Those should be examined to see if they are really intended. – barbara beeton Jul 09 '19 at 20:16
  • 3
    Really, I see no overspacing, apart from the space explicitly inserted with \,. Note that if you use the (horrible) French notation for intervals, it should be \mathopen]a,b\mathclose[ – egreg Jul 09 '19 at 20:17
  • 1
    @egreg too slow:-) – David Carlisle Jul 09 '19 at 20:18
  • @egreg Have you read the thought of David :-)? – Sebastiano Jul 09 '19 at 20:18
  • @Sebastiano no! do not set it each time. If you change the settings (and I see no reaon to change them) then it should be done globally in the document preamble so they are consistent. – David Carlisle Jul 09 '19 at 20:18
  • @Sebastiano no we just looked at the output image that you posted, it is clear that the markup is wrong even if you hadn't posted a test document (although the test document was good to conform that) – David Carlisle Jul 09 '19 at 20:19
  • @DavidCarlisle (egreg) So I'm leaving everything as it is? Without actions? If the answer is yes I delete my question. – Sebastiano Jul 09 '19 at 20:22
  • 1
    @Sebastiano no there are lots of actions, as the answer shows if you fix your markup the spacing will be better (and generally more even, if not smaller). – David Carlisle Jul 09 '19 at 20:23
  • @DavidCarlisle Could you please edit your answer, following my MWE, to get a better spacing, so I better understand your comment (there are so many actions) on how I should fix my preamble? – Sebastiano Jul 09 '19 at 20:26
  • basically just remove all the \, and change every ]a,b[ to \mathopen]a,b\mathclose[. also use \frac not \dfrac – David Carlisle Jul 09 '19 at 20:27
  • @DavidCarlisle But egreg doesn't like it (horrible french notation) – Sebastiano Jul 09 '19 at 20:29
  • egreg doesn't like pineapple pizza either. There is no hope for him – David Carlisle Jul 09 '19 at 20:30

2 Answers2

3

The general question in the title is a duplicate of

How to get less spacing in math mode

But much of the bad spacing is not due to the general settings but to bad markup, consider for example:

enter image description here

You need to mark ] as a mathopen if you use it as an open delimiter

\documentclass{article}

\begin{document}

$x\in ]a, b[$ % bad

$x\in \mathopen]a, b\mathclose[$ % better

\end{document}

Similarly y'\,f_{yy'} the \, is doing nothing but force a bad space, just use y' f_{yy'}

David Carlisle
  • 757,742
1

The answer is the great user @egreg takes from the chat and it is very important for me. Thank you very much @egreg.

\documentclass[a4paper,12pt]{article}
\usepackage[top=2.5cm,bottom=2.2cm,
            left=3.2cm,right=1.5cm,headsep=10pt,
            a4paper]{geometry}  
\usepackage{amsmath,amssymb,mathrsfs}
\usepackage{newtxtext,newtxmath}

\newcommand{\diff}{\mathop{}\!d}

\newcommand{\tder}[2]{\frac{\diff #1}{\diff #2}}
\newcommand{\pder}[2]{\frac{\partial #1}{\partial #2}}

\newcommand{\iv}[3][c]{%
  \csname iv@#1\endcsname{#2}{#3}%
}
\makeatletter
\newcommand{\iv@gen}[4]{#1#3,#4#2}
\newcommand{\iv@c}{\iv@gen{[}{]}} \let\iv@cc\iv@c
\newcommand{\iv@o}{\iv@gen{\mathopen]}{\mathclose[}} \let\iv@oo\iv@o
\newcommand{\iv@co}{\iv@gen{[}{\mathclose[}}
\newcommand{\iv@oc}{\iv@gen{\mathopen]}{]}}
\makeatother

\begin{document}

Ovviamente deve essere $1-c^2>0$ e cioè $|c|<1$ perchè sia lecita la relazione \ldots. 
La costante arbitraria $c$ può avere segno qualsiasi; deve aversi cioè per ogni 
$x\in \iv[o]{a}{b}$, $y'(x)=c/\sqrt{1-c^2}$ oppure $y'(x)=-c/\sqrt{1-c^2}$. 
Potrebbe essere $c=0$ compatibile solo con $y(a) = y(b)$, segmento parallelo all'asse~$x$. 
Se $c\ne 0$, allora anche $c/\sqrt{1-c^2}\ne 0$, e dovendo $y'$ essere continua non può 
accadere che per certi $x\in\iv[o]{a}{b}$ valga il segno $+$ e per altri il segno $-$ 
(altrimenti $y'$ salterebbe senza assumere i valori intermedi fra $c/\sqrt{1-c^2}$ e 
$-c/\sqrt{1-c^2}$). Deve quindi valere $y'(x)=c/\sqrt{1-c^2}$ per ogni $x\in]a,b[$, 
oppure $y'(x)=-c/\sqrt{1-c^2}$ sempre per ogni $x\in]a,b[$: dato che $c$ è, 
come detto prima, costante di integrazione indeterminata, non si perde nulla a 
scrivere $y'(x)=c/\sqrt{1-c^2}$ qualunque sia $c$. Posto $m=c/\sqrt{1-c^2}\in \mathbb{R}$, 
ed essendo $c$ variabile in $\iv[o]{-1}{1}$ allora $m=c/\sqrt{1-c^2}$ assumerà tutti 
i valori reali. La soluzione generale dell'equazione di Eulero è $y(x)=mx+k$; dovendo 
essere $y(a)=\alpha$ ed $y(b)=\beta$ si ricava $ma+k=\alpha$ ed $mb+k=\beta$, da cui 
$m=(\beta-\alpha)/(b-a)$ e $k=\alpha-a(\beta-\alpha)/(b-a)$. Ma ci si poteva fermare 
una volta scoperto che $y'$ deve essere costante: questo prova che le uniche soluzioni 
sono segmenti di rette come il percorso più breve, e ce n'è uno solo che passa per due 
punti dati $(a,\alpha)$ e $(b,\beta)$, come ben sappiamo. La funzione integranda non 
dipende esplicitamente da $x$ quindi il funzionale è del tipo
\[
\mathscr{F}(y)=\int_{a}^{b}f(y,y')\diff x
\]
In questo caso l'equazione di Eulero-Lagrange  
\[
\tder{}{x} \pder{f(y,y')}{y'}-\pder{f(y,y')}{y}=0
\]
Se poi $y$ è di classe $\mathcal{C}^2$ in $[a,b]$ diventa, dalla \eqref{elfd2}, per 
il teorema di derivazione delle funzioni composte,
\begin{equation}\label{edex}
f_{y}(y,y')-f_{y'y}(y,y')y'-f_{y'y'}(y,y')y''=0
\end{equation}
Moltiplicando la \eqref{edex} per $y'$, otteniamo l'equazione di Eulero-Lagrange è
\[
\tder{}{x}(f-y'\,f_{y'})=0.\]
Infatti si ha
\[
\begin{split}
\tder{}{x}(f-y'f_{y'})
  &= f_y\,y'+f_{y'}y''-y''f_{y'}-(y')^2f_{yy'}-y'y''f_{y'y'} \\
  &= y'(f_y-y'f_{yy'}-y''f_{y'y'})=y'\cdot 0=0.
\end{split}
\]

\end{document}
Sebastiano
  • 54,118