8
votes
3answers
516 views

Without any built-in looping macro, can we just use a recursive macro to get a-b-c-d-e?

Without any built-in looping macro, can we just use a recursive macro to get an output of a-b-c-d-e? \def\aaa #1{#1-\aaa} \aaa abcde % expected result : a-b-c-d-e \bye Edit: Probably the best way ...
6
votes
1answer
62 views

Is it possible to know the actual length of a rubber length

The MWE is A \hskip 0pt plus 2pt \foo B \end Then macro \foo will tell me the actual length of the previous \hskip in the log file. Is it possible to write such macro \foo? How?
1
vote
2answers
68 views

amsmath, vec and if not working together

I am trying to define some macros in which I need an "if" which test contains an argument of the macro. The issue arises when this argument is \vec{<arg>} and the amsmath package is loaded. Here ...
9
votes
1answer
126 views

Multilevel bullets

I want to write something that I could use for multilevel bullets, for example: I. Title Subtitle a. sub-subtitle ... In LaTex I got \def\startitems { \begingroup \parindent\z@ ...
6
votes
4answers
145 views

How to write a TeX macro that accepts a number or a \count register as argument?

What's the most simple way, in plain TeX, to define a \macro that can be used as: \macro{10} \macro{\mycount} such that I can then assign the number to a \count and manipulate it? Note: ...
5
votes
1answer
152 views

Separating a decimal in any format into integer and fractional parts in basic LaTeX

Note: I've separated this question from what was becoming a very tangled discussion. I know egreg already has a solution, so I'll just wait until he posts it here. Question: The solution has to take ...
9
votes
2answers
201 views

Still having difficulty with use of `\expandafter`

Firstly, my apologies for any previous confusion, I've separated out various questions onto distinct pages. This problem came up in the context of trying to split a decimal number. Good solutions to ...
22
votes
1answer
554 views

Use of \relax after \ifnum … \fi construction

I'm reading Malcolm Clark's A Plain TeX Primer. On page 111 there's an exercise to define a macro that prints the current time. I've reproduced Clark's answer below: \newcount\minleft ...
7
votes
1answer
66 views

I need an hrule, but not when at the top of the page

I have a multi-page document that has many small sections split with \hrule lines. Occasionally a section will end immediately before a page break, and so the next section will begin right at the top ...
15
votes
1answer
215 views

Behavior of \\ in Plain TeX

According to \show, the pre-defined control sequence \\ is supposed expand to its argument without the suffix "pt": This is TeX, Version 3.1415926 (TeX Live 2012/Debian) **\show\\ > \\=macro: ...
5
votes
1answer
108 views

Using end-of-line delimiter in plain Tex macro

How is it possible to use the end-of-line character as a macro parameter ? I would like something along the lines of : \def\mymacro#1\endlinechar{Content:#1} \mymacro First content \mymacro Second ...
13
votes
2answers
162 views

An hbox-vbox-halign permeable macro, is it possible?

I currently have a Plain TeX file which does something like this in a multitude of places: \indent\hbox{\vbox{\halign{#\hfil\quad&#\hfil\cr ... table content here ... }}} I would love to ...
6
votes
1answer
107 views

amstex: operator definition error

I can't understand why the following code give me an error \input amstex.tex $\mathop{\rm arctg}(x)$ \bye Thus, the input does not work with my macros that include the use of \rm, \mathop, etc., ...
7
votes
4answers
211 views

Special macro definition (2opt, 1mand)

How can you define a macro \cmd in TeX primitives using two optional arguments (and a mandatory one) that fulfills the property that calling \cmd[opt]{mand} is equivalent to \cmd[][opt]{mand}. Yet, I ...
2
votes
2answers
126 views

Kind of spurious space

I'm trying to write a \spaced macro: it takes a string as parameter, decompose that string and then recompose it spreading avery token from the others according to a given \spreadratio. Here are the ...
7
votes
3answers
170 views

\csname error in defining in loop

In following snippet I try to use TeX programming to define commands \Ab, \Bb, \Cb and so on. Strangely, I get Missing \endcsname inserted error. What is my mistake? I hadn't read TeXBook, so it is a ...
13
votes
3answers
706 views

Examples of list macros in plain TeX

I'm writing macros to typeset lists in plain TeX. Please can you suggest some examples of macros for numbered lists? I'd prefer examples from "living code", from CTAN packages and so on. But any kind ...
6
votes
3answers
259 views

What's the difference between format and macro language?

From a comment by morbusg depends on what you mean by "plain tex": if you mean "plain tex – the macro language", then yes, LaTeX does provide an interface. If you mean "plain tex – the ...
15
votes
1answer
527 views

Transition from LaTeX to Plain TeX

For several reasons I need to typeset in Plain TeX, however I have always worked with LaTeX. So how hard will this be? I basically need something like the book or report documentclass (with toc, ...
2
votes
1answer
127 views

gensym for TeX?

In other macro systems (notably Lisp's), one often needs to store results into "temporary" variables which shouldn't clash with any variables in the environment where the macro is called. In Lisp, the ...
5
votes
3answers
1k views

Why does TeX not like \usepackage?

My prof writes papers with harvmac, which is apparently incompatible with LaTeX. Fine, I switch to tex. Now TeX gives me Undefined control sequence when I type \usepackage{amsmath}. There's gotta ...
2
votes
1answer
194 views

Can I write a macro for placing a vertical, breakable rule along arbitrary paragraphs without an output routine?

I answered a question last week about creating a continuous but breakable rule next to an arbitrary number of paragraphs in Plain TeX. My solution gathered the paragraphs to rule in a vbox; my output ...
5
votes
3answers
1k views

Plain TeX vs. LaTeX Macros

I was wondering what's the (advantage) of doing something one way over the other in different systems. For instance, I read that users of plain TEX should use \def whenever they want to create a new ...
6
votes
2answers
205 views

Toggling Phantom In Macros (plain TeX)

I am using plain TeX / pdfTeX. Is there a way to build a set of macros, say \showOn / \showOff, such that I can nest them for a given piece of text, it "looks up the parse tree", find the first ...
4
votes
1answer
137 views

What's special about \def\\ vs. \def\mksp?

In the following definitions, \\ captures a space token but \mksp does not. \documentclass{article} \begin{document} {\def\\{\global\let\sp= } \\ } {\def\mksp{\global\let\spx= } \mksp } \show\sp ...
6
votes
2answers
180 views

Executing TeX commands s.t. (1) produces empty boxes (2) and no other output

EDIT: I need plain TeX, not LaTeX. Furthermore, I don't want to use an existing package -- I want to reinvent the wheel. [This is part of a complicated set of TeX macros I have set up; and I need to ...
8
votes
1answer
357 views

Execute token after \halign

I like to create a macro which processes a following brace group as "argument" using \halign. After it has been processed a token (a macro) should be executed. With an \hbox I can use ...
6
votes
3answers
220 views

How to define a macro containing a tabbed line (\+…\cr)?

\def\test{\+test\cr} \test \vfill \eject The above gives error: ... Runaway definition? -> ! Forbidden control sequence found while scanning definition of \test. ...
2
votes
1answer
396 views

Scope of catcode change for escape character ?

In the following macro, I change the category code for the escape character (\) to "other" (12): \def\xxA{\begingroup \catcode`\\ = 12 \gdef\xxB ##1z{\tt ##1\endgroup} \xxB} How the heck does ...