zauguin / luaul

7 stars 3 forks source link

Highlighting of texttt #8

Closed leomayer closed 3 years ago

leomayer commented 3 years ago

When I highlight a text which is encapsulated in a texttt the highlighting seems to have random additional space in front. e.g.

\newcommand{\code}[1]{ \highLight[{[HTML]{D3D3D3}}]{\texttt{#1}}}
* Die Kapiteln können nur dann in der Lasche \code{Bearbeiten} gesehen werden, wenn der Benutzer im Gesamtdokument die Berechtigung \code{Zugang} hat.

See as well https://tex.stackexchange.com/q/596753/48642. The reverse order of commands works fine.

zauguin commented 3 years ago

It's not random... Whenever one of the \test... commands is used at the beginning of the lua-ul command, the space immediately before the command is affected by the lua-ul command too. That's an artifact of how LaTeX inserts italic correction there: \texttt and friends remove the last space (and penalty), add some italic correction and then reinsert the space (and penalty). The issue is that his reinsertion happens inside of \highLight and therefore the space is highlighted.

I'll have to think about this to see if it can be avoided.

zauguin commented 3 years ago

If you don't need italic correction you can avoid this by using \ttfamily instead:

\newcommand{\code}[1]{\highLight[{[HTML]{D3D3D3}}]{\ttfamily #1}}
leomayer commented 3 years ago

With random I meant the space in front of the word. As you can see in the screenshot the width of highlighted text in front is not the same length. This seems to be corrected with 1.4.

zauguin commented 3 years ago

With random I meant the space in front of the word. As you can see in the screenshot the width of highlighted text in front is not the same length.

They are just normal spaces, their width is influenced by TeX's justification. The first line is slightly stretched, so all spaces are a bit wider than in the second line which is set at the natural width.

This seems to be corrected with 1.4.

??? Where did you get a version 1.4?

leomayer commented 3 years ago

This seems to be corrected with 1.4.

??? Where did you get a version 1.4?

Ohhh... seems like I missed something - its 1.3. :-/

zauguin commented 3 years ago

Ohhh... seems like I missed something - its 1.3. :-/

Actually it's 0.1.3.

Anyway, this is fixed in the real v0.1.4.