4

This question has been asked for several times, notably here. However, most solutions involved the package xspace which, as I heard, should be avoided.

I'm currently using the following definitions:

\newcommand{\ie}{\emph{i.e.}\@ifnextchar.{\!\@gobble}{}}
\newcommand{\eg}{\emph{e.g.}\@ifnextchar.{\!\@gobble}{}}
\newcommand{\etc}{etc\@ifnextchar.{}{.\@}}

which produce result like this:

enter image description here

However, since I'm not familiar with the TeX macros involved, I'm not sure if the spacing shall always be correct. Also, the post-spacing seems to vary with different fonts used (e.g., with Palatino Linotype as the main font, the spacing after i.e. seems larger, and I shall have to change \! to \!\!). And the main drawback of these definitions is that a simple \ie without . after it shall produce a large whitespace.

As this seems to be a very basic question, I think there should be some very mature solutions. Is there an existing package, or an existing set of macros that can do this perfectly?

Below is a MWE.

\documentclass{article}

\usepackage{newpxtext}

\makeatletter \newcommand{\ie}{\emph{i.e.}@ifnextchar.{!@gobble}{}} \newcommand{\eg}{\emph{e.g.}@ifnextchar.{!@gobble}{}} \newcommand{\etc}{etc@ifnextchar.{}{.@}} \makeatother

\begin{document}

Some text, \ie. some explanations.

Some text, \ie, some explanations.

Some text, \eg. some examples.

Some text, \eg, some examples.

Some text, \etc. Here is another sentence.

Some text, \etc, continuing.

\end{document}

Jinwen
  • 8,518

1 Answers1

1

Just for referencing, here are some of the commands defining with expl3. They can be followed by a dot ., a comma , or an empty group {}.

If your i.e. is always followed by a comma, then the following definition behaves the same as \newcommand\ie{\textit{i.e.}} noted by David Carlisle in his comment to the question; in other cases, the following version should behave a little better.

\documentclass{article}

\usepackage{newpxtext}

\ExplSyntaxOn

\NewDocumentCommand { \ie } { } { \textit{i.e.} \peek_meaning_ignore_spaces:NTF . { \skip_horizontal:n { -.3ex } \use_none:n } { \peek_meaning_ignore_spaces:NF , { \skip_horizontal:n { -.3ex } } } } \NewDocumentCommand { \eg } { } { \textit{e.g.} \peek_meaning_ignore_spaces:NTF . { \skip_horizontal:n { -.3ex } \use_none:n } { \peek_meaning_ignore_spaces:NF , { \skip_horizontal:n { -.3ex } } } }

\NewDocumentCommand { \etc } { } { etc. \peek_meaning_ignore_spaces:NT . { \use_none:n } }

\NewDocumentCommand { \cad } { } { \textit{c-à-d.} \peek_meaning_ignore_spaces:NTF . { \skip_horizontal:n { -.3ex } \use_none:n } { \peek_meaning_ignore_spaces:NF , { \skip_horizontal:n { -.3ex } } } } \ExplSyntaxOff

\begin{document}

Some text, \ie. some explanations.

Some text, \ie{} some explanations.

Some text, \ie, some explanations.


Some text, \eg{} some examples.

Some text, \eg. some examples.

Some text, \eg, some examples.


Some text, \etc. Here is another sentence.

Some text, \etc, continuing.

Some text, \etc{} continuing.

Some text, etc. Here is another sentence.

Some text, etc., continuing.


Quelques textes, \cad, quelques explications.

Quelques textes, \cad. quelques explications.

Quelques textes, \cad{} quelques explications.

\end{document}

enter image description here

Jinwen
  • 8,518