# Tag Info

6

My first source is TeX.SX! I learned here so much about TeX/LaTeX and macro expansion and still feel sometimes a little uneducated, but it's improving ;-) However, if there is no precise question (title) on what one is looking for, some manuals are perhaps the better choice. My main printed source is the TeX by Topic book by Victor Eijkout, but it's some ...

5


5

From my experience as an end usr, and not a pro developer, I would say you are on the right track: first, find a need (something you need), and then try to write a package to solve that need. In the process check reliable documentation (I often perused source2e.pdf and the source code of the base LaTeX classes.pdf, all available at the base directory of ...

4

The names beginning with \end.... are reserved for implementing the end codes of environments, so you can not define \endexer with \newcommand. You could call the command \stopexer or \exerend or anything else that does not start with \end.

4

The problem when you do \def\@unit#1 is that the argument will never be the brace, but all that goes from the open brace to the matching closed one and your test is never successful. You can do it with \futurelet, but you'll be tied to a very inflexible system of input. Here's an expl3 implementation that's possibly clearer than \futurelet. ...

4

Assuming you want input syntax \unit{kg}{m} what you need to do is use the TeX primitive \futurelet to search for an upcoming {. If there is one, we can grab a (braced) argument, typeset it in math mode then loop. Note that this approach requires braces around each argument. \documentclass{article} \makeatletter \def\unit{% \$% ...

4

You can correct the spacings with etoolbox: \documentclass{gsm-l} \usepackage[papersize={160mm,240mm},inner=20mm, outer=15mm, vmargin=15mm]{geometry} \geometry{includeheadfoot} \usepackage{fouriernc} \usepackage{esvect} \usepackage{amsmath,enumitem} \usepackage{remreset} \usepackage{etoolbox} \usepackage{pgf,tikz} \usetikzlibrary{arrows} \makeatletter % ...

4

\newcommand{\mymacro}[2]{%% \expandafter\providecommand\expandafter *\csname#1autorefname\endcsname{#2}%% } then if #1 is zzz \zzzautorefname will be defined.

3

The whole cube can be drawn in one \draw statement. The calculations can be also be done using the new TikZ library math, either via \tikzmath{...} or key evaulate: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{math} \newcommand{\drawbox}[3]{% \draw[ evaluate={ \angle = 30; \xd = 2/3*cos(\angle); \yd = ...

3

For its internal purposes, bytefield changes the category code of & upon starting the environment. This change cannot affect the argument already absorbed by \bansen, so you have to do the category change beforehand: \documentclass{article} \usepackage{bytefield} \newcommand{\bansen}{% \begingroup\catcode`&=10 \banseninternal} ...

3

You could prefix the correct answer by * and test for it, using \CorrectChoice for this case and \choice for the others; then you can use the standard exam features for hiding or showing the correct choice: removing the answers option will hide the correct answers. \documentclass[ a4paper, addpoints, answers, 12pt ]{exam} ...

2

My possible solution uses the tocloft facilities to generate a \listof... for the enums and items counters (autodefined by \newlistof). In addition, \xapptocmd from xpatch writes the \listofenums and \listofitems entries by using \addcontentsline. There is one backdraw so far: It's not possible to define a title for the \listof... entry. ...

2

Also, the LaTeX kernel provides \@namedef for this: \makeatletter \newcommand*{\mymacro}[2]{% \@namedef{#1autorefname}{#2}% } \maketatother Indeed, the task you want to accomplish is a pretty common one: just think of how labels for cross-referencing are defined. Caveat: In contrast with the \providecommand solution, \@namedef will silently overwrite a ...

2

An expl3 way to do this could be: \usepackage{xparse} \ExplSyntaxOn \cs_new:Npn \mathfortyfive_maybe_define:Nn #1#2 { \cs_if_free:NT #1 { \cs_new_nopar:Npn #1 {#2} } } \cs_generate_variant:Nn \mathfortyfive_maybe_define:Nn { cn } \NewDocumentCommand \mymacro { mm } { \mathfortyfive_maybe_define:cn { #1 autorefname } { #2 } } \ExplSyntaxOff There may ...

2

Try to grab a copy of TeX for the Beginner by Wynter Snow. She teaches you how to handle the basics of Plain programming (regardless of engine: she explains TrueTeX) and makes frequent cross-references for the experienced LaTeX user. You may use some of her macros together with eplain to mimick some functionality of LaTeX. And if you want to handle multiple ...

1


1

Here's one possible solution: Define macros \startsource and \stopsource which take on the values associated with your choices. This way you can specify a single block to import the listing. \makeatletter \define@key{MEMacros}{color}{\def\ME@color{#1}} \define@key{MEMacros}{decorations}{\def\ME@decorations{#1}} ...

1

Quoting from one of the comments: “Solutions with non-letter characters are welcome”. So, I present a solution that extracts arguments made entirely of letter (\catcode = 11) characters, up to, but not including, the first non-letter. In principle, the code could be adapted to include the ten digits 0…9 as well. This solution requires nothing more than ...

1


1

I've never done this with lists, but I've done it with drafts of textbooks in order to provide easy links from exercises to their answers in the back of the book. For me, I used the newfile package, which allowed me to essentially duplicate the TOC, LOT, and LOF mechanisms for exercises. For each exercise, I printed the exercise itself on the current page, ...

1

You could abuse xparse for this by assuming the first argument is correct and allowing a star * to indicate an other correct answer. By checking against all the arguments, you can toggle which are correct. Note that this solution is shaky: it will allow multiple correct answers in choices 2–5, but each of these will cause choice 1 to be incorrect. For ...

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