# Tag Info

12

Yes, of course. \documentclass{article} \begingroup \catcode+=\active \gdef+{\mathbin{\mathrm{blurb}}} \endgroup \AtBeginDocument{\mathcode+="8000 } \begin{document} $x+y$ \end{document} Of course you can think to better definition for the “math active” +. ;-)

7

Let's do it slowly: \ignorepars\par x becomes \futurelet\next\ignoreparsA\par x Now \next is \let to \par and \ignoreparsA is expanded, so we have \ifx\next\par\expandafter\ignorepars\eat\fi\par x The conditional is true, so \ifx\next\par disappear, leaving \expandafter\ignorepars\eat\fi\par x Now \expandafter expands \eat, which has empty ...

7

A delimiter is needed to convince the environment macro (or any other macro) that the argument list is finished and all other stuff is not to be processed by the macro itself. This delimiter is a {}, empty space is ignored. See the examples where foobar uses [...] as normal text, whereas foobaropt expects an optional argument and interpretes it that way ...

6

this has lots less finesse than egreg's suggestion, but sometimes brute force works. \let\oldpar\par \def\ignorepar{\let\par\ignorespaces} \def\restorepar{\endgraf\let\par\oldpar} \def\bye{\endgraf\end} \ignorepar abcdef ghijkl mnopqr stuv wxyz abcdef ghijkl mnopqr stuv wxyz abcdef ghijkl mnopqr stuv wxyz abcdef ghijkl mnopqr stuv wxyz \restorepar ...

5

This is very similar to what Leslie Lamport recommends in his LaTeX: A Document Preparation System, except he advises that you enclose the entire [ ... ] in braces. It really comes to very much the same thing, by having {[ ... ]}, you are telling LaTeX that [ ... ] is to be taken separately. I suppose with {} you are almost providing insulation, if you see ...

5

Improved code with 'grouping' of persons and hyperlinks (if needed) \documentclass{book} \usepackage{marginnote} \usepackage{xparse} \usepackage{totcount} \usepackage{morewrites} \newcounter{dummycounter} \newcounter{personposition} \newtotcounter{personcounter} \makeatletter \def\latex@starttoc#1{% \begingroup \makeatletter \@input{\jobname.#1}% ...

5

xint should have a binomial function but I forgot to include it in the last release. Here is one way in the meantime: The update has permuted the order of presentation, as testing proved that the simpler approach using the built-in factorial was significantly faster except for cases with a small #2. \documentclass{article} \usepackage{xintexpr}% at least ...

4

The basic idea is to use TikZ's graph-drawing mechanism. It accepts something like \graph{/--{/--{/,/},/}}; to draw a graph. So the next step is to translate [ is /--{ ] is } , is , . is / This is quite hard since TikZ does not like \graph\bgroup/--\bgroup/--\bgroup/,/\egroup,/\egroup\egroup; (Internally every pair of { and } will become an ...

4

This is not possible. TeX sees \par. At this point the current horizontal list is split into a vertical list of horizontal boxes, hyphenation is applied if necessary, discardable glue is discarded and left and right glue is added. Then the output routine is invoked, which may output one or more pages, possibly taking stored inserts and footnotes, and ...

4

inside \parbox, tabular p columns, minipage etc, various commands are normalised to a known state, specifically they all run \@arrayparboxrestore which by default is \def\@arrayparboxrestore{% \let\if@nobreak\iffalse \let\if@noskipsec\iffalse \let\par\@@par \let\-\@dischyph \let\'\@acci\let\\@accii\let\=\@acciii \parindent\z@ \parskip\z@skip ...

4

Spaces need special treatment to be ignored as they are character tokens but \par is a csname so you can more simply do \let\par\empty (which latex does for example in tabular) (obviously you need some hook such as end of group to restore the definition if \par is ignored in this manner.)

3


3

This generates the counter on the fly although this is not recommended in any case. If the counter name given as first argument already exists, there is a command \c@#1 already which is LaTeX representation of a counter (well, top layer on \count.... registers actually. If \@undefined{c@#1} is true, define the new counter and set it to one, displaying ...

3

Let's see what happens with the call \long\def\linesaver#1{\obeylines#1} \linesaver{ Test1 Test2 } Since \linesaver has one argument, TeX absorbs it and performs tokenization; so the end-of-lines get changed into space tokens before \obeylines enters into action. It does when the argument has already been absorbed, so there's no ^^M in the argument and, ...

3

Use \newcommand{\Prof}{Prof.\@} as a possible macro for replacing the text easily with a single change. Be careful about using \Prof in conjunction with text later on (which is very likely), since whitespace is gobbled and the text is glued to the expansion of \Prof. If you don't mind be struck down by the thunderbolts by egreg use xspace ;-) ...

3


3

A variant of Symbol1's answer that doesn't require auxiliary files. However, for technical reasons, instead of a period a * is used. \documentclass{article} \usepackage{tikz} \usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered} \newcommand{\setupbseriesactive}{% \begingroup\lccode~=`[ \lowercase{\endgroup\def~{/--\iftrue{\else}\fi}}% ...

3

You can use the powerful apnum macros. \documentclass{article} \input apnum \def\binom#1#2{{\evaldef\n {#1} \evaldef\k {#2}% \evaldef\X {\FAC{\n}/(\FAC{\k}*\FAC{\n-\k})}\X}} \begin{document} \binom{2^4-3}{2^3} \end{document} Note that apnum can also be used in plain TeX, because it does use only TeX primitives. (And also note the joke message ...

2

Glyphs can be larger than their bounding box: \documentclass{article} \begin{document} \fboxsep0pt \fbox{$\widetilde{\mathbf{l}}$} \end{document} You can enlarge the border of preview by changing the length \PreviewBorder

2

You need to change \def\ba#1{\begin{array}#1} to \def\ba#1{\begin{array}{#1}} Observe the pair of curly braces around #1 in the second line of code. Incidentally, you shouldn't use  directly in a LaTeX document to initiate and terminate displaymath mode; use $and$ instead. For more information on this subject, see the postings Why is [ ... ] ...

2

You could use forest to draw the trees. Since it requires a specification of a tree in brackets notation, it seems at least potentially suitable. Unlike the existing solutions, this one does not require LuaTeX. The examples below were compiled using pdfTeX, but any engine should work. I present 2 versions: The Original Edition requires you to write [] ...

2

I think that bm can be helpful: \documentclass{article} \usepackage{amsmath} \usepackage{bm} \newcommand{\tn}[1]{\bm{\mathsf{#1}}} \begin{document} Good sizes (and $\mathsf{A}$ for comparison) $h=\tn{A}+\tn{B}^2 + \hat{\tn{C}}$ But the sizes are bad when superscripts or subscripts are involved ...

2

The error is telling you that \xspace is undefined, presumably because you have not loaded the package of that name

2

Create you own package, and put them in your texmf tree. A package is just a macro file with these characteristic: .sty extension no need of \makeatletter…\makeatother a \ProvidesPackages command. using \RequirePackage instead of \usepackage. You should indeed versionning it, for example with git. Cf my own macro file ...

2

I suggest to use xparse and \RenewDocumentCommand with provides easier ways to define macros with optional arguments The argument specification somo says to use a starred (#1), optional (#2), mandatory (#3) and a final optional argument (#4), if needed. Redefining the sectioning commands should be done with care since they provide a starred variant which ...

1

If you really want the last be optional then use the TeX level for the new command: \documentclass{article} \makeatletter \def\mysec#1#2{\@ifnextchar[{\mysec@i{#1}{#2}}{\mysec@i{#1}{#2}[]}}% \def\mysec@i#1#2[#3]{% \textbf{#1} \\ #2 \ifx\relax#3\relax \else \\ #3 \fi}% or whatever you want to do with #3 \makeatother \begin{document} \mysec{foo}{bar} ...

1

You might do like the following: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{mfirstuc} \usepackage{titlesec} \titleformat{\section} {\normalfont\scshape} {\thesection} {1em} {\makefirstuc} \begin{document} \section{Capital} \section{capital} %\section{équipe} \end{document} but, as soon as the third \section command is ...

1

As mentioned in the comments to the question, defining a new command as \\\\ is impossible, because redefining \ conflicts with the existing meaning of \ used as an escape sequence. Even if \\\\ seems to be more convenient to type instead of \\[\normalbaselineskip], this is not a good coding practise (loss of readability). Use cases like adding more ...

1

The currfile package provides several methods to get the name and the path of the current file. For instance, you can use the \currfilename macro: \ClassError{myclass}{Entry requires version selection using \protect\selectversion \on@line (\currfilename)}{} Note that it might not work in some cases. For instance, if you load the currfile package in a ...

1

For automatic sizing of material in subscript and superscript positions, don't use the basic \mbox command. (Here, "basic" means "defined in the LaTeX kernel.) Instead, be sure to load the amsmath package and use the \text command. The setup of the \tn macro should thus be as follows: \newcommand{\tn}[1]{\text{\boldmath$\mathsf{#1}$}} Because \tn only ...

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