Suma

Suma

ingrese la descripción de la imagen aquíingrese la descripción de la imagen aquíEstoy tratando de componer un libro antiguo en el que noto que todos los números están rodeados por 1 punto (excepto si es el primero en una línea, en cuyo caso no hay ningún punto antes ni el último en una línea, en cuyo caso no hay ningún punto después). ). Si está presente, el punto está dentro del espacio normal entre palabras (como si por sí solo no ocupara espacio).

¿Hay alguna forma en (lua)TEX (uso contexto) para componer números de esa manera?

Lo intenté de manera muy ingenua, pero no descarta los puntos al principio o al final de las líneas, y supongo que también hay problemas si el pegamento se encoge demasiado.

\starttext

\dorecurse{100}{
Le \llap{.}1\rlap{.} element. }

\stoptext

Probé cleaders(que son descartables), pero los puntos están centrados (y no cerca del dígito) y no parecen estirarse como esperaba.

Imagen agregada para ilustración. Esto muestra que los puntos se descartan al final de las líneas pero todavía hay demasiado espacio alrededor de los números.

Ejemplo de tipografía antigua (Biblia francesa Olivetan, pdf disponible enhttp://www.e-rara.ch/gep_g/content/titleinfo/1751440si te gusta la tipografía gótica. No es fácil en el libro cuál es la cantidad de espacio.

Respuesta1

El orden en el que combinas los dos saltos (el \leadersy el que no es \leadersuno) no importa: siempre desaparecerán como una unidad.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\makeatletter

\newsavebox\@NWD@dot@box
\newlength\@NWD@space@skip
\newcommand*\numberwithdots[1]{%
    \unskip
    \setbox\@NWD@dot@box \hbox{.}% use current font
    \@NWD@space@skip
        \fontdimen\tw@ \font
        \@plus \fontdimen\thr@@ \font
        \@minus \fontdimen 4 \font
    \hskip \glueexpr \@NWD@space@skip-\wd\@NWD@dot@box
    \cleaders \copy\@NWD@dot@box \hskip \wd\@NWD@dot@box
    #1%
    \cleaders \copy\@NWD@dot@box \hskip \wd\@NWD@dot@box
    \hskip \glueexpr \@NWD@space@skip-\wd\@NWD@dot@box
    \ignorespaces
}

\makeatother



\begin{document}

\numberwithdots{1} note that the indent does \emph{not} count as a ``begin of
line'': not sure if this is what is wanted.  Some text \numberwithdots{2} that
includes \numberwithdots{3} some numbers: I~hope that \numberwithdots{4} some
\numberwithdots{5} of them will fall \numberwithdots{6} on a line boundary,
although \numberwithdots{7} it is \numberwithdots{8} always possible
\numberwithdots{9} to arrange things in order \numberwithdots{10} to make
\numberwithdots{11} this happen.  And it \numberwithdots{12} is also
possible\linebreak[4] \numberwithdots{13} to force \numberwithdots{14} a line
\numberwithdots{15} break\linebreak[4] at a specific \numberwithdots{16}
position.

Two numbers in a row, though, do not \numberwithdots{123} \numberwithdots{456} 
look well.

\end{document}

Este es el resultado que obtengo:

Salida del código

Suma

Quizás sería preferible utilizar espacios más amplios alrededor de los números con puntos; y sería aún mejor permitir al usuario personalizar este aspecto.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\makeatletter

\newsavebox\@NWD@dot@box
\newlength\@NWD@space@skip
\newcommand*\@NWD@factor{1.5} % redefine default as you please
\newcommand*\numberwithdots[1]{%
    \unskip
    \setbox\@NWD@dot@box \hbox{.}% use current font
    \@NWD@space@skip
        \@NWD@factor\fontdimen\tw@ \font
        \@plus \fontdimen\thr@@ \font
        \@minus \fontdimen 4 \font
    \hskip \glueexpr \@NWD@space@skip-\wd\@NWD@dot@box
    \cleaders \copy\@NWD@dot@box \hskip \wd\@NWD@dot@box
    #1%
    \cleaders \copy\@NWD@dot@box \hskip \wd\@NWD@dot@box
    \hskip \glueexpr \@NWD@space@skip-\wd\@NWD@dot@box
    \ignorespaces
}
\newcommand*\nwdsetdotspacing[1]{\def\@NWD@factor{#1}}
\newcommand*\nwdlinebreak{\unskip\unskip\linebreak}

\makeatother



\begin{document}

\numberwithdots{1} note that the indent does \emph{not} count as a ``begin of
line'': not sure if this is what is wanted.  Some text \numberwithdots{2} that
includes \numberwithdots{3} some numbers: I~hope that \numberwithdots{4} some
\numberwithdots{5} of them will fall \numberwithdots{6} on a line boundary,
although \numberwithdots{7} it is \numberwithdots{8} always possible
\numberwithdots{9} to arrange things in order \numberwithdots{10} to make
\numberwithdots{11} this happen.  And it \numberwithdots{12} is also
possible\nwdlinebreak[4] \numberwithdots{13} to force \numberwithdots{14} a line
break \numberwithdots{15}\nwdlinebreak[4] at a specific \numberwithdots{16}
position.

Two numbers in a row, though, do not \numberwithdots{123} \numberwithdots{456} 
look well.

\nwdsetdotspacing{} % empty argument amounts to 1

\numberwithdots{1} note that the indent does \emph{not} count as a ``begin of
line'': not sure if this is what is wanted.  Some text \numberwithdots{2} that
includes \numberwithdots{3} some numbers: I~hope that \numberwithdots{4} some
\numberwithdots{5} of them will fall \numberwithdots{6} on a line boundary,
although \numberwithdots{7} it is \numberwithdots{8} always possible
\numberwithdots{9} to arrange things in order \numberwithdots{10} to make
\numberwithdots{11} this happen.  And it \numberwithdots{12} is also
possible\nwdlinebreak[4] \numberwithdots{13} to force \numberwithdots{14} a line
break \numberwithdots{15}\nwdlinebreak[4] at a specific \numberwithdots{16}
position.

\nwdsetdotspacing{2}

\numberwithdots{1} note that the indent does \emph{not} count as a ``begin of
line'': not sure if this is what is wanted.  Some text \numberwithdots{2} that
includes \numberwithdots{3} some numbers: I~hope that \numberwithdots{4} some
\numberwithdots{5} of them will fall \numberwithdots{6} on a line boundary,
although \numberwithdots{7} it is \numberwithdots{8} always possible
\numberwithdots{9} to arrange things in order \numberwithdots{10} to make
\numberwithdots{11} this happen.  And it \numberwithdots{12} is also
possible\nwdlinebreak[4] \numberwithdots{13} to force \numberwithdots{14} a line
break \numberwithdots{15}\nwdlinebreak[4] at a specific \numberwithdots{16}
position.

\end{document}

Desafortunadamente, por una razón tecnológica, para forzar un salto de línea, también tuvimos que reemplazar el \linebreakcomando con nuestro \nwdlinebreak.

Producción:

Salida del segundo ejemplo de código

Un grado adicional de libertad: un factor también para la cantidad de retroceso. Además de esto, el siguiente extracto de código presenta una implementación alternativa y más sólida:

\makeatletter

% Alternative approach that permits nesting: use temporaries, but with grouping:
\newcommand*\@NWD@dot@factor{}
\newcommand*\@NWD@spc@factor{1.5}
\newcommand*\numberwithdots[1]{%
    \unskip
    \setbox\z@ \hbox{.}% use current font
    \dimen@ \@NWD@dot@factor\wd\z@
    \skip@
        \@NWD@spc@factor\fontdimen\tw@ \font
        \@plus \fontdimen\thr@@ \font
        \@minus \fontdimen 4 \font
    % More elegant with subroutines (or perhaps not):
    \@NWD@nonleader@hskip \@NWD@leader@hskip
    {#1}%
    \@NWD@leader@hskip \@NWD@nonleader@hskip
    \ignorespaces
}
\newcommand*\@NWD@nonleader@hskip{%
    \hskip \glueexpr \skip@-\dimen@ \relax % for robustness
}
\newcommand*\@NWD@leader@hskip{%
    \cleaders \copy\z@ \hskip \wd\z@
}
\newcommand*\nwdsetdotspacing[2][]{%
    \def\@NWD@dot@factor{#1}%
    \def\@NWD@spc@factor{#2}%
}
\newcommand*\nwdlinebreak{\unskip\unskip\linebreak}

\makeatother

Lecturas adicionales

El truco de incluir un cuadro en una masa de pegamento como \leaders, para que desaparezca en los saltos de línea o de página, es bien conocido: hasta donde yo sé, fue propuesto por primera vez por Marcin Woliński en 2007, véaseCómo hacer que un cuadro desaparezca en un salto de línea.

Ver también:

Respuesta2

\input expl3-generic % just for not using ConTeXt

\ExplSyntaxOn
\cs_set_eq:NN \dorecurse \prg_replicate:nn
\ExplSyntaxOff

\def\num#1{\unskip\adddot#1\adddot\ignorespaces}
\def\adddot{%
  \cleaders\hbox to 1.5\dimexpr\fontdimen2\font-\fontdimen4\font\relax{\hss.\hss}%
  \hskip1.5\fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font
}

\dorecurse{100}{The \num{2} element \num{2} xy. }

\bye

ingrese la descripción de la imagen aquí

Si se debe adjuntar el punto al número, es aún más sencillo.

\input expl3-generic

\ExplSyntaxOn
\cs_set_eq:NN \dorecurse \prg_replicate:nn
\ExplSyntaxOff

\newbox\periodbox

\def\num#1{\leavevmode\addleftdot#1\addrightdot}
\def\addleftdot{%
  \setbox\periodbox=\hbox{.}%
  \cleaders\copy\periodbox\hskip\wd\periodbox\relax
}
\def\addrightdot{%
  \setbox\periodbox=\hbox{.}%
  \cleaders\copy\periodbox\hskip\wd\periodbox\relax
}

\dorecurse{100}{The \num{2} element \num{2} xy. }

\bye

ingrese la descripción de la imagen aquí

información relacionada