Linked Questions

75
votes
8answers
9k views

Does TeX/LaTeX give a headstart with other programming languages?

I've seen many programmers here at tex.se, and I'd like to know how they view TeX/LaTeX as a programming language in relation to other languages, and whether it would boost my progress as a beginner ...
60
votes
6answers
13k views

Will two-letter font style commands (\bf , \it , …) ever be resurrected in LaTeX?

I understand that \bf and \it are now obsolete in LaTeX and that \textbf and \textit are proper, as they produce more sophisticated (in particular, cumulative and properly kerned) changes to font ...
66
votes
3answers
2k views

Advantages and disadvantages of fully expandable macros

As I currently understand them, fully-expandable macros are analogous to pure/effect-free functions in functional programming. Correspondingly, things that are not expandable, such as \def, are ...
49
votes
4answers
17k views

How can I check in LaTeX (or plain TeX) whether a command exists, by name?

I'm looking for a LaTeX way to control macro expansion, contingent on some macro being defined or not. I'm looking for something like this (but then actually working): \newcommand[1]{\checkfor}{ \...
41
votes
4answers
2k views

TeX macro idioms, or: understanding advanced macros

I often find that when I look at solutions from the experts here, the macro definitions are completely inscrutable to me. Trying to use standard techniques one would use to understand code in most ...
29
votes
3answers
799 views

Why the \expandafter\@firstoftwo idiom?

I see a lot of macros which are conditional tests followed by a {true}{false} pair defined so that they result in either: \expandafter\@firstoftwo or \expandafter\@secondoftwo Why are these \...
15
votes
3answers
2k views

How to implement a command that checks for loaded packages?

I use the following code to check if a package is loaded: \RequirePackage{ltxcmds} \newcommand{\IfPackageLoaded}[2]{\ltx@ifpackageloaded{#1}{#2}{}} However, sometimes I want to check if more than ...
9
votes
3answers
696 views

Defining tabular rows with macros using `\ifnum` leads to `Incomplete \ifnum`

I am trying to define tabular rows using a macro which shall perform an conditional definition of the tabular row according to a given parameter. Please consider the following MWE: \documentclass{...
7
votes
2answers
1k views

problem with \ifthenelse + multicolumn

I encounter various problems when i want to control the display of a table with a ifthenelse test. For example, consider the following M(non)WE : \documentclass{article} \usepackage{multirow} \...
7
votes
2answers
480 views

How to specify a default value for overlay specification in \newcommand<>?

I have something like this: \documentclass{beamer} \newcommand<>{\mycommand}[1]{\textcolor#2{red}{#1}} \begin{document} \frame{ \mycommand{test} } \end{document} I want the command to ...
5
votes
2answers
290 views

\href macro in \section conflicts with local hyperref linking in ToC

If I have a section like so \section{Section 1} then in the ToC, so long as I use the hyperref package, it is linked to that particular section. However, if I use an href tag as the section name,...
1
vote
1answer
131 views

Conditional based on packageoption

I added a counter to the todonotes packages \todo so I could display the total number of todos I have left. However I also enjoy working with the package option disabled. Therefore I would like to ...
2
votes
1answer
99 views

Using the tabu environment, within a conditional, within newenvironment

I am getting error messages (“Misplaced alignment tab character &.”) when I define a tabu environment within a conditional, with \newenvironment. Can this be avoided? Here is a minimal working ...
1
vote
0answers
64 views

Modify `\funcdef` macro to use `pgfkeys` instead of `keyval`

I attempted to modify the \funcdef macro from egreg's solution from A macro adding or removing parenthesis automatically to use pgfkeys, but am running into some difficulty (probably related to some ...