Tag Info

New answers tagged

5

If you start a paragrah inside a vbox (or vcenter) the lines will be broken to \hsize which is \textwidth here which is wider than you want. You should use a tabular which will vertically centre and look more like latex. All LaTeX box and rule commands consistently start a paragraph (so \rule here) but TeX primitives like \hbox do not.


3

For printing a length in sp units, define \newcommand\lengthinsp[1]{\number\dimexpr#1\relax sp} This will accept \lengthinsp{\parindent} (with a register) or even \lengthinsp{3.5in}. Example: \documentclass{article} \newcommand\lengthinsp[1]{\number\dimexpr#1\relax sp} \begin{document} \lengthinsp{\parindent} \lengthinsp{3.5in} \end{document} ...


7

$ tex \\relax This is TeX, Version 3.14159265 (TeX Live 2014) (preloaded format=tex) * (Please type a command or say `\end') *\dimen0=3.5in *\showthe\dimen0 > 252.94499pt. <*> \showthe\dimen0 ? *\count0=\dimen0 *\showthe\count0 > 16577003. <*> \showthe\count0 dimen values are just integer values interpreted as sp so you can do the ...


5

This looks like an issue with the engine that has been reported here and will be fixed in the next release.


8

You may be interested in Doug McKenna's report on his project re-implementing TeX in Objective C. I don't believe the video is out yet. (He named a multi-year time but I'm afraid I don't remember it exactly.)


1

I'am using toks register \tabdata for such purposes where the \halign preamble is created step by step. The advatage of this is that the macro \table can create arbitrary \halign preamble according to special language offered to user. The algorithm can scan such language and it can create \halign preamble using \addtabdata macro. \newif\ifright ...


1

You can put expanded value of the register to the macro \m. No matter if eTeX is used or isn't, because we needn't to use \dimexpr. \def\m#1{{ \dimen0=200pt \#1=#1 % Outputs 200pt rather than 100pt }} \dimen0=100pt \expandafter\m\expandafter{\the\dimen0}


1

If you use e-TeX, you can avoid using a register, exploiting the fact that \dimexpr is essentially a nameless dimension register: \def\m#1{\expandafter\minner\expandafter{\the\dimexpr#1\relax}} \def\minner#1{{\dimen0=200pt \#1=#1}} The input \dimen0=100pt \m{\dimen0} will produce #1=100.0pt Without e-TeX and \dimexpr, the workaround is to reserve a ...


9

You can pretend to have two # in the template by using a macro: \newif\ifright \def\table{% \halign{% \def\temp{##}\ifright\hfil\temp\else\temp\hfil\fi\cr Bla-bla\cr aaaaaaaaaaaaaaaaaaa\cr }% } % \rightfalse \table \righttrue \table \bye Alternatively, use \span \newif\ifright \def\table{% \halign{% ...


6

As an alternative to Joseph's you can hide the duplication in a macro (at the expense of passing each cell through a macro expansion) \def\foo#1{\iftrue\hfil#1\else#1\hfil\fi} \def\table{% \halign{\foo{##}\cr Bla-bla\cr}} \table \bye


6

Are you looking for something like the following \let\hash\relax \def\table#1{% \edef\preamble{\iftrue\hfil\hash\else\hash\fi\cr}% \let\hash## \expandafter\halign\expandafter{\preamble #1}% \let\hash\relax } \table{a\cr b\cr} \bye The idea here is that during the 'construction' phase we represent # using a non-expandable token; only during the ...


10

An \outer macro is illegal only in a skipped branch of a conditional (and in arguments to macros, but it's not relevant here). What happens when TeX processes a conditional in the form <if><test><true text>\else<false text>\fi where <if> stands for a primitive conditional and <test> is the list of tokens required by it ...


6

This is a dump of the hashtable that stores the command names. \documentclass{article} \newcommand\wibble{hello} \begin{document} \directlua{ for i, v in pairs (tex.hashtokens()) do texio.write_nl(i) end} \end{document} it outputs a long list, but testing with lualatex testfile.tex | grep wibble produces wibble Showing it includes all commands ...


8

You need to separate out the choice of the : and _ syntax of L3 from the functionality. The following uses a much smaller expansion library than xparse (just 7 lines of code) but it implements the n (no expansion) x (full \edef expansion) and o (expand once \expandafter) expansion types. Rather than define variant macro names with :nnx suffixes, just ...


4

It's easy with expl3: \input expl3-generic \def\arga{what} \def\argb{how} \ExplSyntaxOn \cs_new:Npx \zh_cmda: { \arga\argb } \cs_new:Npn \zh_cmdb:nn #1 #2 { \str_if_eq:nnTF { #1 } { what } { \msg_term:n{\#1~is~`what'} } { \msg_term:n{\#1~isn't~`what'} } \str_if_eq:nnTF { #2 } { how } { \msg_term:n{\#2~is~`how'} } { ...


11

With \def\a#1{\ifx E#1\else \b\fi} the call \a ABC takes A as the argument to \a, so the input stream becomes \ifx EA\else\b\fi BC and, since the condition turns out to be false, what remains in the input stream is \b\fi BC Thus the arguments to \b are #1<-\fi and #2<-B, so we get [\fi:B]C Now \fi performs its duty of disappearing and you ...


5

\b grabs the \fi but if you use the following definition of \a, the you obtain the expected output: \def\a#1{\ifx E#1\else \expandafter\b\fi} The above completes the conditional \if..\fi before processing \b. \documentclass{article} \begin{document} \def\a#1{\b} \def\b#1#2{[#1:#2]} \a ABC \def\a#1{\ifx E#1\else \b\fi} \a ABC \def\a#1{\ifx E#1\else ...


4

If you need this for coping with old files, you can do this way \input eplain \catcode`@=11 \def\stringify#1{% \expandafter\let\csname zh@\string#1\endcsname#1% \def#1##1{% \begingroup\def\temp{##1}% \edef\x{\endgroup \expandafter\noexpand\csname zh@\string#1\endcsname{% \expandafter\strip@prefix\meaning\temp}% }\x }% } ...


6

Not sure this works in general, but works here (delete any existing .aux file first) \input eplain %\input eplain-2.1/eplain \let\oldxrdef\xrdef \def\xrdef#1{\expandafter\oldxrdef\expandafter{\string\string\string#1}} \let\oldxrefn\xrefn \def\xrefn#1{\expandafter\oldxrefn\expandafter{\string#1}} define at \xrdef\input and refer to \xrefn\input done \bye


5

No. The \special there is not understood by tex at all it is just passed verbatim into the dvi file to whatever program process that file. That particular syntax is for the dvips driver, it would not necessarily be understood by other dvi to ps or dvi to pdf/svg/... programs and viewers. You can of course hide the platform differences behind macros giving ...


5

The tex executable runs the “original Knuth TeX”, whereas \pdfpagewidth is a pdftex primitive. The usual \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname pdfpagewidth\endcsname\relax \else \pdfpagewidth 8.5 truein \pdfpageheight 11 truein \fi will do. After it, \pdfpagewidth and \pdfpageheight will not be ...


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 ...


10

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


14

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 ...



Top 50 recent answers are included