# Tag Info

## Hot answers tagged tex-core

21

The history about the pica pint is quite interesting (at least for me). And it has to do with the way we measure types. In the beginning From the early days of the emergence of the printing press, and the mythical Gutenberg and for a long time, each printer, each workshop had its own way of measuring the types used. Its own scale. This scale was arbitrary ...

19

The size of a printer's point was fixed at the Fifteenth Meeting of the Type Founders Association of the United States in 1866 as 0.013837 in (see this Wikipedia page. Quoting from the TeXbook (chapter 10): The units have been defined here so that precise conversion to sp is efficient on a wide variety of machines. In order to achieve this, TeX's ...

17

The \expandafter primitive expands after exactly one token: it does not take two arguments. As such \expandafter\uppercase{\xx} skips over \uppercase and tries to expand {, which is unexpandable and so nothing happens. Thus this is entirely identical to simply writing \uppercase{\xx} Thus in general what you have to do to expand the argument after a ...

14

Multiplication and division by integers is possible. So you can do this: \newskip\foo \newskip\bar \foo=10pt plus 2pt minus 3pt \bar=\foo\relax \multiply\bar by 10 \divide\bar by 4 \showthe\bar \bye

14

This answer provides the line by scaling the line character. A closer look at the character bounding box reveals, that there is some slanted part sticking to the left and right. Scaling would also alter the angle of the slanted part. Therefore the implementation constructs the line with three parts: begin part by clipping the rest of the glyph scaled main ...

13

Or possibly with \beginL etc added to force direction. \documentclass{article} \usepackage{fontspec} \setmainfont[ExternalLocation,Scale=3]{amiri-regular} \newcommand\mymacro[4]{\makebox[#3]{#1\leaders\hbox{#2}\hfill#4}} \begin{document} مــــــــــــــــــــــن \mymacro{م} {ـ} % this is the Kashida {100pt} {ن} \end{document} adding some overprinting ...

13

The primitive \span has two very different meanings if it appear in the preamble of \halign or in the body. If it's in the preamble, that is before the first \cr it means “expand” the following token; if it appears in the body it ends the current cell, but merges it with the following one. In this case it's usually in combination with \omit. The simplest ...

13

Taking the example (following the edit), I'll start giving a very detailed view of the first couple of lines then move on a bit more rapidly. Dan has noted the fact that there is a bit of processing to normalise 'lines': I'm going to assume we can move on to the char-by-char reading of each line. The bottom line here is that TeX reads the input from the ...

11

Multiplying by a decimal factor is allowed only for a <dimen>; when a <glue> is used, it is coerced to a <dimen>. The syntax for a <dimen> includes <factor><unit of measure> and <unit of measure> can be <internal dimen> (any dimension register) or <internal glue> (any glue register); see the TeXbook, ...

11

You can use \separateskip macro which separates the three parts of the skip register to the three dimens. The macro scans the \the output of the register. The usage is: \separateskip\foo to \dimA \dimB \dimC Now, the base part is stored in \dimA, the stretch part in \dimB and the shrink part in \dimC. You can do, for example: \bar=2.5\dimA plus 4.7\dimB ...

10

You can use my macro \seplist exactly for purposes described in your question. The macro \seplist has the following syntax: \def\yourmacro#1{... macro with normal #1 without separator} \seplist{list of separators}\yourmacro parameter text For example: \def\macro#1{parameter is: "#1"} \def\separed{\seplist{{sepA}{SepB}{SEPC}}} \separed\macro text ...

10

\documentclass{article} \usepackage{plain} \begin{document} \begin{plain} \input{texfile} \end{plain} \end{document}

10

For clarity I'll denote space tokens by •, as they are very important in the discussion; spaces in the following code samples should be ignored. The parameter text of \temp is #1• while the replacement text is \def\tempii{#1} Your call of \temp is \temp\xx a•b•c•\tempii\tempii Notice that after \xx there's a space just for delimiting the macro; it ...

8

All processes were explained in detail by Josef Wright and Dan. Maybe only \expandafter should be explained more. The expansion of \expandafter <token1><token2> does: save <token1> to TBRA (= "To Be Read Again queue"). expand <token2> (i.e replace it to "expanded material", if is not expandable then "expanded material" = ...

7

Fully discussing the topic would be really too long, so I'll describe some general facts to give the flavor. Some TeX primitives require very specific tokens to follow them. To make some examples, I'll mention \over that can be followed by anything legal in math mode and \uppercase that, instead, wants to see after it a <general text>. So in the case ...

7

The question gives me a sense if it is read from its end: give the possibility of creating a macro which expands its parameter during parameter scanning. Then the variants } or \egroup as a delimiter of the parameter is serviceable. I've created the \eparam macro with this syntax: \def\mymacro #1{the #1 parameter is declared as undelimited} ... ...

6

I wrote the project that cloutiy mentioned, but I am actually currently in the process of moving away from Pango/Cairo, so I thought it might be worth explaining why. Pango and Cairo worked very well for basic typesetting use; I produced a couple of books using SILE and a Pango/Cairo backend, and they look good. However, there were a number of problems with ...

6

With e-TeX's glueexpr and converting the factor from a real number to an integer ratio: \bar=\glueexpr\foo*5/2\relax This is a "scaling operation, a multiplication followed by a division. In this case e-TeX uses 64-bit for the intermediate value and the result has to fit in the allowed range, of course.

5

I'm still thinking as to why it is, but this revision (embracing \xx) gives you what you want. I think the answer is that, in the usage \temp\xx a b c, the space after \xx is from the TeX parser's view, not a space at all, but merely signifies the end of the macro name \xx. For example, if you just put \xx A on a line by itself, you will see that it prints ...

5

@wipet in his answer has shown how to resolve the problem as long as we can assume that that the \prevdepth of all material in the document is sufficiently small (that it lies below \maxdepth in fact). In that case we can use the depth of box 255 as a measure for the \prevdepthcalculations that will have taken place if there is any remainder in recent ...

5

Unless the line breaks at exactly \hsize if there is no glue it will be infinitely bad (10000) TeX's line breaker is a least cost calculation so the only way to allow it to do exactly what you ask is to set \tolerance=10000 which says to accept arbitrarily bad line breaks. TeX will complain a lot in the log file. Usually it is better to arrange that glue ...

5

The badness of an overfull line without glue is 1000000 (TeXbook, page 229), but TeX won't complain if the length is between \hsize and \hsize+\hfuzz. It will be 10000 if the line is underfull. Here's an example: \line{\hbox to\dimexpr\hsize-1sp{\hfill}} \showthe\badness \line{\hbox to\dimexpr\hsize{\hfill}} \showthe\badness \line{\hbox ...

5

The LaTeX kernel takes several precautions against this: \documentclass{myclass} \usepackage{polyglossia} \setdefaultlanguage{english} \makeatletter \def\@outputpage{% \begingroup \let\protect\noexpand \@resetactivechars \shipout\vbox{ \set@typeset@protect \aftergroup \endgroup \aftergroup \set@typeset@protect \box\@outputbox }% } ...

4

This is more about a comment rather than an answer, but it doesn't fit. I recently came up to a problem with \expandafters and tried to easily understand how it works, so I'll tell here my “process” (altough it's not really well tested). The thing is, how can you “know” what happens with many expandafters? Well, here's my process. I do anotate with a ...

4

If you only want to put counter values in there, you can replace \mytoks=\expandafter{\the\mytoks#1}% by \edef\tmp{\mytoks{\the\mytoks#1}}\tmp as they are safe (and expand) in an \edef)

3

When the OR returns something back to the main vertical list (RET material), then this RET material is inserted (rougly speaking, we don't consider inserts for this case) instead the material packed in box255. No matter if a nonempty remainder is or isn't after it. The interline glue between RET material and nonempty remainder is not calculated again by ...

2


2

Frank, the question itself is a bit of a dilemma, or at least I interpreted it that way. Perhaps I'm wrong. A dilemma because you said, that the real question is ''But what about if it is called by TeX on its own?'' Then you rejected the possibility of having a new primitive. Furthermore, you stated in the comments section, while responding to another ...

1

I know this question has created an argument, and some users here think it's not straightforward nor useful. However, as I said in the question, it was curiosity, so wipet's solution does work. However, I tend to understand much more easier expl3 code rather than the TeX primitives alone (for instance, many macros used here were found just by logic, ...

1

The difficulty, at least with using regexes on a non regular language, is perhaps best seen via an example. Given a command \eqalignno, one could perhaps try a multiline match with, say, awk: /\\eqalignno\{/, /^ +\}\$/ { do_something } (match for a range, starting with the pattern inside the first //, and continue on until finding the second pattern. But ...

Only top voted, non community-wiki answers of a minimum length are eligible