Tag Info

Hot answers tagged

18

You could use { \globaldefs=1 \makefoobar } All assignments are global while \globadefs is non zero. Beware though, lots of things will break with the setting, use with care.


11

TeX has a fixed number (256 in classic TeX 32768 in etex and xetex and 65536 in luatex) of registers which store integer values. \newcount\c allocates the name \c to one of these registers, and classic TeX primitives like \advance operate on them, note that addition here involves assignment back to the register so it is not an expandable operation. LaTeX's ...


9

It's easy to get a special after the math: \tracingonline1 \tracingoutput1 \showboxdepth100 \showboxbreadth100 \def\efoo{\special{end foo}} \everymath{\special{begin foo}\aftergroup\efoo} % where to put \special{end foo} \everydisplay{\special{begin foo}\aftergroup\efoo} % ditto Regular text $a+b=c$ more text $$\sqrt{x}=y$$ \bye Produces ...\mathon ...


8

\def\makefoobar#1{% #1\def\foo{foo}% #1\def\bar{bar}% } Now you can use one of \makefoobar{} \makefoobar{\global} \makefoobar{\global\long} or all the other combinations. The prefixes \global, \long, \outer and \protected (the last one only if the engine uses e-TeX extensions) only apply to the next token and they do expansion because they must be ...


6

Possibly something like this? It preserves the OP's desired syntax \ifnot\tobe, while at the same time not demanding that \tobe be predefined. Additionally, for those who don't like using \tobe without defining it, it allows the alternate syntax \ifnot{tobe}, without any changes whatsoever. \documentclass{article} \makeatletter % Following 3 lines thanks ...


6

Using e-TeX and assuming \escapechar is printable and not a space: \documentclass{standalone} \makeatletter \newif\if@to@be@ \def\if@not#1{% \expandafter\unless\csname \expandafter\expandafter\expandafter i% \expandafter\expandafter\expandafter f% \expandafter\@gobble\string#1\endcsname } \begin{document} \@to@be@true \if@not\@to@be@ Not ...


6

The calculation of "plus and minus" results are done in TeX using computer-dependent implementation of numbers, so Knuth decided that there will be no possibility to access these results by macro programmer in order to disable of creating computer-dependent results in document by macro language. I suggest the macro \roundto{dimen}. This macro recalculates ...


4

Having the full conditional in the argument to \ifnot is essential for the macro to work, or it cannot appear in another conditional, because TeX keeps track of \if..., \else and \fi in skipped text. Assuming the conditional \iftobe is defined, your macro should work like \ifnot{tobe}Not to be\else To be\fi Now let's try \iftrue \ifnot{tobe}Not to ...


3

You have to redefine the splitting macro each time, as you don't know what the separator will be at calling time: \def\Split(#1){% \makexSplit \expandafter\xSplit\expandafter{\sep}{#1}% } \def\xSplit#1#2{\xxSplit#2#1\endpiece#1} \def\makexSplit{% \begingroup\edef\x{\endgroup\def\noexpand\xxSplit####1\sep}% \x{% \def\temp{##1}% ...


3

My solution redefines \newif macro. The new \newif\iffoo declares \iffoo and \ifnotfoo testing macros and (as usually) \footrue and \foofalse setting macros. Of course, no packages are needed. The testing macros are skipable in nested \if..\fi constructions. \def\sdef#1{\expandafter\def\csname#1\endcsname} ...


2

You can define \declaresplitsep macro which redefines the \split macro with desired separator: \def\dosomethingwithsplitofpiece#1{*#1} \def\declaresplitsep#1{% \def\split(##1){\splitA##1#1#1}% \def\splitA##1#1{\ifx#1##1#1\else\dosomethingwithsplitofpiece{##1}\expandafter\splitA\fi}% } \declaresplitsep, \split(4,5,6,7,9,10,11) \declaresplitsep; ...


2

Here's another idea. \documentclass{scrartcl} \usepackage{etoolbox} \makeatletter \newcommand\gobblethree[3]{} % poor hackish solution expecting usual escapechar \newcommand*\newifnot[1] {\newif#1% \csappto{\expandafter\gobblethree\string#1true}% {\cslet{\expandafter\newifnotaux\string#1}\iffalse}% \csappto{\expandafter\gobblethree\string#1false}% ...


1

In this case you only need the monospace (typewriter) font, not the other features of \lstinline, so you can just use \texttt. As @barbarabeeton points out, to get a proper backslash in the same font, use this: \char`\\ So the command you need is this: \subsection{\texttt{\char`\\dot}} If you do this a lot, because it's TeX you can devise macros: ...


1

As David Carlisle wrote above, package varwidth is the way to go. It provides environment varwidth which does what I was asking for. Here is a minimal example to draw text on a gradient shaded background using beamer. \documentclass{beamer} \usepackage{calc,varwidth} \colorlet{titleshadeA}{white!30!orange} \colorlet{titleshadeB}{red!30!black} ...



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