# Tag Info

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

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

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

7

The main error is that \relax isn't undefined. This test file is complete and can be run through latex, the terminal output is macro:-> macro:->streeeet macro:->ciiity2222 which is (I think) what you want in each of the three cases. \makeatletter \def \mystreet#1{\def\@mystreet{#1}} % Defines the \name command to set name \def ...

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

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

You can store the "message" in the main vertical list about the end of previous environment using very specific value of penalty. And you can read this value at the start of your environment. \newenvironment{env} {\ifnum\lastpenalty=12345 \vskip-\bigskipamount \penalty0 \fi \addvspace{\bigskipamount}\bfseries} ...

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

5


5


4

You have several bad % in your code. Always leave a space after a constant (or add \relax. In particular the bad one is at \ifnum\value{mycnt}>0% \item[item \the\mycount] text \fi% When TeX wants to perform this check, it expands \item to see if some more digits come along. In the case hyperref is loaded, the first level expansion of \item is ...

4

You can adjust the definitions so that \THEN does not run \THENtrue \ELSE behaves more like \THEN \FI unindents but prints no keyword as follows \usepackage{program} \makeatletter \def\THEN{\@marginspace\untab\keyword{then}\ \tab} \def\ELSE{\@marginspace\untab\keyword{else}\ \tab}% \def\FI{\@marginspace\untab} \makeatother \documentclass{article} ...

4


4

I searched through the pgf souce for \tikzpictext and found the following solution (more or less): \documentclass[tikz,border=5pt]{standalone} \begin{document} \tikzset{my circle/.pic={ \ifx\tikzpictext\relax \node [draw, thick, circle, minimum width=10pt] {};% \else \node [draw, thick, circle, minimum width=10pt, pin=-90:\tikzpictext] ...

3

The macro \ifthenelse is not provided by default, but needs \usepackage{ifthen} or, better, \usepackage{xifthen}. However, its tests don't (easily) allow for decimal number comparisons. You can do it with PGF features: \documentclass{article} \usepackage{tikz} \newcommand{\first}{My first question. Potentially has more than one line.} ...

2

One way to do this would be to use the environ package to save the \BODY of the document into a \savebox which saves the text passed to the \Slide macro in a list and output the list at the end. The following \begin{document} abc \Slide{Slide 1 content} ghi \Slide{Slide 2 content} jkl \end{document} yields: References: How keep a running ...

2

Your MWE is a composite of various mistakes. First. Numbers can be compared by num=num. The \equal from ifthen.sty package compares strings (after expansion), no numbers. Second. OK, you are using \equal and you have the problem that the \pruns macro includes "0 " (zero space) and you compare it with "0" (zero). These two strings are not equal. The space ...

2

I think it's better to use the \excludecomment macro provided by the comment package. This way you don't need to start and end comment environments from inside macros or environments of your own. \documentclass{article} \usepackage{ifthen} \usepackage{comment} \specialcomment{solution}{\textbf{Solution}\quad}{} \newboolean{iflecturer} ...

2

The xstring package provides two commands: \IfInteger and \IfDecimal. Each of them uses the syntax \IfInteger{<value being tested>}{<result if true>}{<result if false>} If you don't want to differentiate between integers and decimals, we could do \documentclass{article} \usepackage{xstring} \newcommand{\DoStuff}[1]{\emph{#1}} ...

2

This answer, using readarray package, is set up to discern whether the lone character of the file is a "0" or not. If you need a more intricate test (i.e., if the file can be more than a single character), let me know the specifics. The \readdef command places the file contents into a \def, which I then can compare directly with an \if (here I assume the ...

1


1

You can use the environ package instead of comment to discard the content of an environment. \documentclass{article} \usepackage{etoolbox} \usepackage{environ} \newtoggle{lecture} \NewEnviron{myitemize}{% \iftoggle{lecture} {\begin{itemize}\BODY\end{itemize}} {}% } \begin{document} \toggletrue{lecture} The environment is visible ...

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

This is a bit kludgy: \documentclass[11pt]{article} \usepackage{fontspec} \setmainfont{Times New Roman} \usepackage{titlesec} \usepackage[extramarks]{titleps} \newcounter{firstLine} \setcounter{firstLine}{1} \newmarkset{firstLine} \newextramark*{firstLine}{firstLine} \usepackage{xparse} \DeclareDocumentCommand \handleOneArg{m}{ \setcounter{firstLine}{#1} ...

1

If you want to stick with PGF's random function \documentclass{article} \usepackage{pgffor} % you do not need full tikz for this \begin{document} \foreach \i in {1,...,10}{ \pgfmathrandom{2} % store 1 or 2 in \pgfmathresult \ifnum\pgfmathresult>1% My first question.% Potentially has more than one line.% \else My second question% ...

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