5

I use \textsuperscript at the beginning of words and I have noticed that, as seen on the picture below, the space between the previous word and the superscripted symbol, in case of shrinking, becomes too small as compared to the other spaces.

The problem also arises if using \raisebox instead of \textsuperscript.

EDIT quark67 pointed out that the issue only occurs with LuaLaTeX, not with XeLaTeX.

 \documentclass{article}
 \usepackage[lmargin=2.5cm,rmargin=2.5cm,bmargin=2.5cm,tmargin=3.5cm]{geometry}
 \usepackage{fontspec}
 \usepackage{graphicx}
 
 \setmainfont{Times New Roman}
 \newfontfamily\djvs[BoldFont={* Bold}]{DejaVu Sans}
 
    
 \newcommand{\tech}{\textbf{\textsuperscript{\scalebox{0.85}{\djvs\char"2318}}}}
    
 \NewDocumentCommand{\techlexAUX}{mmm}{\tech\textit{#1}\IfNoValueF{#2}{\textup{\textsubscript{\textsc{#2}}}}\IfNoValueF{#3}{ `#3'}}
 \NewDocumentCommand{\techlex}{>{\SplitArgument{2}{,}}m}{\techlexAUX#1}
 
 \begin{document}
    I'm trying \techlex{arbre,n,tree}.\vspace{1ex}
    
    Similarly, if \techlex{attirement,n,attracting} is essentially found under the affective sense, it nonetheless allows writers to play with the ambiguity between a literal and a figurative interpretation, implying here again a neutral primary meaning inherited from the verb, waiting for further interpretation.
 \end{document}

enter image description here

Now with XeLaTeX (no problem): enter image description here

Bigger symbol, other letter than f, and negative \hspace (back to Lua)

\newfontfamily\symbola{Symbola}[FakeBold=0.5]
\newcommand{\book}{\textsuperscript{\scalebox{1.2}{\symbola\char"1F4D6}}}

enter image description here

With XeLaTeX, the book symbol still has the spacing issue.

enter image description here

With LuaLaTeX:

enter image description here

7
  • 1
    You don't say if you compile with lualatex or xelatex, but when your code is compiled with xelatex the spaces are equals (not a tiny space as in red circle). With lualatex, it's as in your picture. I have just a warning (with the 2 engines) because the Times New Roman in small caps isn't available. I cannot test with your edited code, with the book (\super: undefined command). And I don't have the Symbola font.
    – quark67
    Feb 22, 2023 at 0:39
  • basically lualatex doesn't an italic correction for an upright f (chat.stackexchange.com/transcript/41?m=63038746#63038746). You could make a feature request in the luaotfload repo. Mar 4, 2023 at 13:47
  • @Ulrike Here the example happens to involve an f but this is irrelevant, it happens regardless of the preceding letter. I changed it into a z in the other picture. Mar 4, 2023 at 18:55
  • I don't have the symbola font and can't check the book symbol, with your example with deja vu the z is not a problem. Mar 6, 2023 at 9:16
  • @Ulrike The issue arises with any symbol. You need to type the whole line so that the glue is shrinked. The problem occurs on both my desktop PC and my laptop and I have the latest miktex and Times versions. The difference is small, if you compile with XeLaTeX you can see what the right space should look like. With a bigger symbol such as the book, it's more salient. Mar 6, 2023 at 10:58

2 Answers 2

5
+50

The \textsuperscript command has nothing to do with the issue. The letter ‘f’ in Times New Roman protrudes a lot right of its bounding box:

enter image description here

The picture for TeX Gyre Termes would be

enter image description here

Unfortunately, no italic correction is provided (maybe it can be added with LuaLaTeX, so instead of an \hspace{...} command you could type \/).

\documentclass{article}
\usepackage[lmargin=2.5cm,rmargin=2.5cm,bmargin=2.5cm,tmargin=3.5cm]{geometry}
\usepackage{fontspec}
\usepackage{graphicx}

\setmainfont{Times New Roman}[
  SmallCapsFont=TeX Gyre Termes,
  SmallCapsFeatures={Letters=SmallCaps},
]
\newfontfamily\djvs[BoldFont={* Bold}]{DejaVu Sans}

\newcommand{\tech}{%
  \textsuperscript{%
    \scalebox{0.85}{%
      \djvs\bfseries\symbol{"2318}%
    }%
  }%
}
    
\NewDocumentCommand{\techlexAUX}{mmm}{%
  \tech\hspace{-0.1em}%
  \textit{#1}%
  \IfNoValueF{#2}{\textsubscript{\upshape\scshape #2}}%
  \IfNoValueF{#3}{ `#3'}%
}
\NewDocumentCommand{\techlex}{>{\SplitArgument{2}{,}}m}{\techlexAUX#1}
 
\begin{document}

I'm trying \techlex{arbre,n,tree}.

\bigskip
    
Similarly, if \techlex{attirement,n,attracting} 

Similarly, if\hspace{0.1em} \techlex{attirement,n,attracting} 

\end{document}

Notes

  1. I streamlined the commands.
  2. The \kern in the definition of \tech doesn't seem necessary.
  3. The symbol should be nearer the italic word that follows, rather than farther.
  4. I added support for small caps, since my version of Times New Roman hasn't them.
  5. I changed graphics to graphicx: you don't want the 1993 version, do you?

enter image description here

22
  • I added another picture to show that even with for example a "z", and even with a negative hspace, the space is reduced with bigger symbols. This one is actually the one which I had a problem with. Feb 22, 2023 at 0:27
  • 1
    @VincentKrebs I get the same effect with XeLaTeX. It's possible that, on your machine, XeLaTeX and LuaLaTeX are choosing different versions of Times New Roman. On mine, the one provided by macOS is used with both engines /System/Library/Fonts/Supplemental/Times New Roman.ttf
    – egreg
    Feb 22, 2023 at 9:43
  • 1
    @VincentKrebs I still cannot reproduce the problem. And on my system (TL on Windows), both XeLaTeX and LuaLaTeX give the same result.
    – Cicada
    Feb 23, 2023 at 2:19
  • 1
    @VincentKrebs LuaLaTeX: the fonts used are listed in the log. XeLaTeX: do fc-list at the command prompt (i.e., list the fonts in the font-cache), and then scan through the output.
    – Cicada
    Feb 23, 2023 at 2:32
  • 1
    @VincentKrebs I deleted the answer I previously posted. Apparently did not grasp the question.
    – user287367
    Feb 27, 2023 at 2:19
1

I was told not to edit initial questions too much, so here is a little recap. Not much more than what egreg said, though.

In order to compensate for bad italic correction or large symbols, the best is to add a space inside the command, this way :

\documentclass{article}

 \usepackage[lmargin=2.5cm,rmargin=2.5cm,bmargin=2.5cm,tmargin=3.5cm]{geometry}
 \usepackage{fontspec}
 \usepackage{graphicx}
 
 \newfontfamily\symbola{Symbola}[FakeBold=0.5]
 \newcommand{\book}{\textsuperscript{\scalebox{1.2}{\symbola\char"1F4D6}}}
 
 \setmainfont{Times New Roman}
 \newfontfamily\djvs[BoldFont={* Bold}]{DejaVu Sans}
 
    
\newcommand{\tech}{\textbf{\textsuperscript{\scalebox{0.85}{\djvs\char"2318}}}}
    
\NewDocumentCommand{\techlexAUX}{mmm}{\hspace{0.05em}\tech\textit{#1}\IfNoValueF{#2}{\textup{\textsubscript{\textsc{#2}}}}\IfNoValueF{#3}{ `#3'}}
\NewDocumentCommand{\techlex}{>{\SplitArgument{2}{,}}m}{\techlexAUX#1}
 
\NewDocumentCommand{\booklexAUX}{mmm}{\hspace{0.05em}\book\textit{#1}\IfNoValueF{#2}{\textup{\textsubscript{\textsc{#2}}}}\IfNoValueF{#3}{ `#3'}}

\NewDocumentCommand{\booklex}{>{\SplitArgument{2}{,}}m}{\booklexAUX#1}
 
\begin{document}
    
Similarly, iz \techlex{attirement,n,attracting} is essentially found under the affective sense, it nonetheless allows writers to play with the ambiguity between a literal and a figurative interpretation, implying here again a neutral primary meaning inherited from the verb, waiting for further interpretation.
    
Similarly, if \techlex{attirement,n,attracting} is essentially found under the affective sense, it nonetheless allows writers to play with the ambiguity between a literal and a figurative interpretation, implying here again a neutral primary meaning inherited from the verb, waiting for further interpretation.
    
        
Similarly, iz \hspace{0.1em}\booklex{attirement,n,attracting} is essentially found under the affective sense, it nonetheless allows writers to play with the ambiguity between a literal and a figurative interpretation, implying here again a neutral primary meaning inherited from the verb, waiting for further interpretation.
        
Similarly, if \hspace{0.1em}\booklex{attirement,n,attracting} is essentially found under the affective sense, it nonetheless allows writers to play with the ambiguity between a literal and a figurative interpretation, implying here again a neutral primary meaning inherited from the verb, waiting for further interpretation.

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .