[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#413449: tex-common: minor issues in section 2.1 of TeX-on-Debian.pdf



Frank Küster <frank@debian.org> wrote:

> We can fix the first issue in two ways:
>
> --- tex-sed
> +++ tex-sed.new
>  #!/bin/bash
>  sed -e 's@TeX@\\TeX{}@g;
>  s@La\\TeX@\\LaTeX@g;
>  s@Debian-\\TeX{}-policy@Debian-TeX-policy@g;
> +s@\\TeX{}MF@TeXMF@
>  s@Metafont@\\MF{}@g;
>  /fontenc/ a \\\\usepackage{mflogo}' < $1 > $2

IMHO, it's the wrong approach to first replace all TeX occurrences, and
then undo all bad side effects this may have had. Because I think there
are too many possible side effects of this kind, due to files or
environment variables that have TeX in their name (we're lucky
environment variables are usually capitalized).

> or more generic
>
> --- tex-sed
> +++ tex-sed.new
>  #!/bin/bash
> -sed -e 's@TeX@\\TeX{}@g;
> +sed -e 's@TeX @\\TeX{} @g;

That's much better and I don't have any example of a false positive this
could trigger (except it's incomplete, see below). But this still relies
on "luck". This works because:
  - basically, everything ending in TeX that is neither a file name nor
    an env var should be typeset with \TeX (I'm thinking of things like
    sliTeX, foilTeX and stuff like that for which we proably don't have
    a logo);
  - file names don't end with a space (even if they end in TeX, there
    is the DebianDoc markup at the end of the file name);
  - env vars are usually capitalized; maybe we also use a DebianDoc
    markup for them, which would avoid the problem even for an env var
    ending in TeX?

So, I'm not very fond of that approach, because it relies on luck, even
if it should "almost always" work. Personally, I'd rather:
  - either have macros that are expanded by a preprocessor such as M4;
    we would have to write something like _TeX, _LaTeX, etc. every time
    we want a special typesetting (I've already done that in docs of
    mine). But it's a bit painful to write, and one tends to forget the
    underscore from time to time.
  - or have a whitelist-only approach.

The latter means something like:

s@(^|[[:space:]])TeX([[:space:]]|$)@\1\\TeX{}\2@g
s@(^|[[:space:]])LaTeX([[:space:]]|$)@\1\\LaTeX{}\2@g
s@(^|[[:space:]])pdfTeX([[:space:]]|$)@\1pdf\\TeX{}\2@g
s@(^|[[:space:]])TeX-related([[:space:]]|$)@\1\\TeX-related\2@g
etc.

where we list all cases needing a special formatting. This looks a bit
more reliable to me. I don't think there are so many cases to list, and
this is easier to adapt if e.g. pdfTeX has his own \pdfTeX command that
does a better formatting than pdf\TeX.

> but then we miss phrases like TeX-related.  We can extend the regex for
> a hyphen:
>
> sed -e 's@TeX\([ -]\) @\\TeX{}\1@g;
>
> but that looks ugly, and there may be other characters than space and a
> hyphen? 

This misses the end of a line.

-- 
Florent



Reply to: