Articles of macros

How do I make a command to display a custom title page?

I followed the advice on the question What do \makeatletter and \makeatother do? to try to make a custom command that displays a custom title page, but it is not working. ./article.tex:17: You can’t use `\spacefactor’ in vertical mode.\@ ->\spacefactor \@m l.17 \makecustomtitle Sorry, but I’m not programmed to handle this case; I’ll just pretend […]

Command which uses brackets automatically when applied to more symbols

How can I define a command like *, similar to \newcommand{\astcommand}[1]{{#1}^*} but which, when applied to a single symbol a, gives the output a*, and when applied to multiple symbols, like abc, automatically adds brackets to the output, like (abc)*? I mean, without having to call it with brackets, as in \astcommand{(abc)} just \astcommand{abc}

Expansion Issues When Passing TikZ Styles to Macro Created by Macro

I’m struggling (again) with expansions. This time I have a generic function \misdirection that creates a TikZ environment subject to a few options. Then, I create a macro \freezeStyle that creates a new macro that has frozen some of the options to \misdirection. So \freezeStyle receives the style that I ultimately want passed to \misdirection. […]

Delimiting-a-macro-with-itself-chain

Reading this question and the answer of @Werner made me think about if it is possible to have chains of self-delimiting macros like \XX abc \XX def \XX xyz or lets say \begin{someenv} \XX abc \XX def \XX xyz \end{someenv} The original definition will obviously fail here – insufficent number fo \XXs. So, a first […]

Find number of occurrences

Is it possible to change te outcome of a command depending on how many times it is called? I would like to have a command with 3 possible outcomes. Case 1: Outcome A in case it only occurs once in the document. Case 2: Outcome B for the first time it occurs in a document […]

Outputting internal at-macro via newcommand?

Just noticed a somewhat strange behavior, when trying to show internal Latex @ commands from main document via \newcommand. Consider the following MWE, where all instances of the internal macro ( \c@something) calls are already wrapped in \makeatletter/\makeatother: \documentclass[10pt]{article} % define internal at-macro \makeatletter \def\c@something{AAA} \typeout{ == \c@something == } \makeatother % define a newcommand […]

General way to split a line by a rule of thumb and displaying results

The following is to construct illustrations for concepts of frequency of a properly sampled outcome if any such frequency exists. Doing such illustrations is tedious and liable to error by hand … so it’s best to make a pair of macros and make a macro out of them that does the following: Suppose I have […]

Capacity exceeded while implementing lookup table

I’d like to implement simple key-value lookup table. I wanted to do it in functional fashion, so I’ve defined initial state of such table as get function causing error (as table is initially empty). Then I’ve defined put function that redefined get do that if its argument equals get argument, it should return value and […]

Define newcommand with multiple sorted mandatory arguments that can be empty

I’m trying to define a command that will take 3 arguments each one possibly empty. An empty argument will slightly modify the output. Let me give a non-working example : \newcommand{\foo}[3]{ \textbf{bar}( \ifthenelse{\isempty{#1}} {} {#1, } #2) \ifthenelse{\isempty{#3}} {} {\cap #3} } And this is what I would like to get : \foo{a}{b}{c} => \foo{}{b}{} […]

Override positioning of all figures

I’m designing all the figures for a book and I wanted to be able to change the positioning [hbtp] of all of them with one macro/command. A solution in which I could override the existing positioning options would be even better. Is that possible?