# Tag Info

165

A bit of background first. When Knuth wrote TeX, he realised that most macros would not need to absorb more than one paragraph as an argument. As a result, a good way to test for errors such as a missing } is to forbid macros to accept paragraph tokens (either those generated by blank lines or explicit \par tokens). So he created \def for definitions which ...

43


36

LaTeX3 solution: \documentclass{article} \usepackage{xparse} \NewDocumentCommand\foo{s}{% \IfBooleanTF#1% {blahblah}% If a star is seen {blah}% If no star is seen }

35

According to the Companion: [\newcommand*] defines a [command], that is not, in TeX terms, long. This means that the newly defined command does not accept empty lines or \par. This is also the default behaviour of \def, while the unstarred version is actually equivalent to \long\def.

34

If you look at source2e you might see a lot of lines that look like \def\foo{\@ifstar\@foo\@@foo} \def\@foo#1{...} \def\@@foo#1{...} This makes \foo a one-argument command that has regular and starred versions. The starred version is the expansion of \@foo while the nonstarred version is that of \@@foo. Using the @ sign in the auxiliary macros is a TeX ...

30

From the TUG faq: use the starred versions figure* and table*. Unfortunately, they're somewhat limited in positioning. Also, the same solution applies to equations. Just include them in a figure* environment. But I don't recommend doing this: it will look ugly and confusing. For an example, see this paper. (sorry, I couldn't find an example in arXiv)

30

To get unnumbered chapters, parts, sections, subsections, etc, you just affix a * (asterisk) to the respective sectioning command; hence, you'd type something like \section*{Acknowledgments} or \chapter*{Introduction} Exactly which sectioning command you ought to use will depend importantly on aspects of the document that you haven't told us about. ...

26

The \\ command is one of the most overloaded commands of LaTeX, i.e., its actual definition depends on the place where it is used. According to the the LaTeX manual by Leslie Lamport (which should be considered the source of truth here) its general definition is \\ produce an explicit line break (or indicate the end of a row etc) \\* produce line ...

23

Write \setcounter{secnumdepth}{1} in your preamble. This says to LaTeX that only first level sections should be numbered; \subsection is level 2. As Gonzalo Medina points out, there's also the tocdepth counter that controls what section levels are included in the table of contents. LaTeX is happy to include also unnumbered section levels in the ToC, it's ...

23

Delay the closing of the group: after _, one can use \bgroup. \documentclass{article} \makeatletter \newcommand\dH{\bgroup d_H\@ifstar{^*\egroup}{\egroup}} \makeatother \begin{document} $B_\dH$ and $B_\dH*$ \end{document} But avoid it.

21

As far as I know there are no such guidelines. As the author (and user) of a macro, you can decide how to use the starred version. But for a little consistency I’d use the star as mark for not numbered if the macro does something with numbering (as in your example). Otherwise I’d prefer to use the non starred version as default (often used) and the starred ...

21

I recommend to create a new macro with a different name instead of changing the behaviour of \section* and thus redefining \section. A separate macro would be a cleaner solution. The main LaTeX command for sectioning is \@startsection. It is documented in source2e.pdf, just type texdoc source2e at the command prompt. You would find it in 61.2 Sectioning. ...

20

Why do we give commands names? To indicate, ideally as clearly as possible, what it is that they do. If you have two things that do very similar things, it makes sense to give them very similar names. On the other hand, if they do one thing significantly differently, you would like to be able to easily tell the two names apart, despite those names being ...

19

Since the \newenvironment command uses a \csname, you can define it directly. \documentclass{article} \newenvironment{test*} {start}{end} \begin{document} \begin{test*} hello \end{test*} \end{document} You can have any combination of characters (with catcode 11 and 12) as you would in a \csname...\endcsname construct, \documentclass{article} ...

18

Spaces (glues and kerns) disappear after line breaks by rule; by the same rule, line breaks can happen only at the "left edge" of a space. Moreover, if one says \hspace{1cm}\hspace{1cm}, the first \hspace is a feasible break point, but not the second one. This is how TeX attains alignment to the left margin for normal and ragged right paragraphs (ragged ...

17


15

It depends how you redefine the command. At the TeX level there is no such thing as a starred variant the base command just looks ahead for a star and acts accordingly. So if you redefine it such that it still looks ahead for the star then it will do so, otherwise it won't. Alternatvely you can save the old command of course. Here the \section commands ...

14

Why? questions can not really be answered except by the person who originally designed the system. But in most languages (certainly most languages of the era) the grammar for names of a language is defined by explicitly listing the allowed characters rather then listing terminating characters. In c or fortran or most other programming languages abc+xyz*rst ...

14


14

(I just learned about this recently:) This can be solved by loading the stfloats package and specifying a figure placement of [bp] as usual. (The p should always be included in case the bottom placement can never be achieved.)

14

The star at the end of the name of a displayed math environment causes that the formula lines won't be numbered. Otherwise they would automatically get a number. You can read about that in the amsmath user's guide since align belongs to amsmath. Such information can usually be found in the package documentation. Type texdoc packagename at the command ...

13

* cannot be used for the name of a control sequence. You must use the \csname...\endcsname pair here : \newenvironment{mequation}{\csname align*\endcsname}{\csname endalign*\endcsname}

13

You can use the starred version of \section, \section*, to produced a non-numbered section as in the following example: \documentclass{report} \begin{document} \section*{Acknowledgement}% This section is not numbered \chapter{Chapter name} \section{Section name}% This section is numbered \end{document} If you want to add the starred section to the table ...

13

Here's a simple solution using the ulem package and the explicit option for titlesec: \documentclass{scrartcl} \usepackage[explicit]{titlesec} \usepackage[normalem]{ulem} \usepackage{lipsum} \titleformat{\section} {\normalfont\Large\sffamily\bfseries\filcenter}{\uline{\thesection\hspace*{ 1em}}}{0em}{\uline{\MakeUppercase{#1}}} ...

13

Building on Gonzalo's answer: Use the numberless key to define the starred version of \section. \documentclass{scrartcl} \usepackage[explicit]{titlesec} \usepackage[normalem]{ulem} \usepackage{lipsum} \titleformat{\section} {\normalfont\Large\sffamily\bfseries\filcenter}{}{0em}{\uline{\thesection\hspace*{ 1em}\MakeUppercase{#1}}} ...

13

Package hyperref needs the counter values to generate unique anchor names. But there are counter values that are not unique. For example, you have several sections with number 1. Because of this, hyperref has introduced \theH<counter> and prefers it over \the<counter> for use in anchor names. \the<counter> might contain weird or duplicate ...

13


13

Some consider it bad practice, as the holy grail of document mark-up is the separation of semantics from styling. An ideal almost achievable with the standard classes. However, the ideal breaks with the starred version of LaTeX sectioning commands as they have the same semantics (but are mostly used for styling). A different approach is to expand the ...

13

In general, there is no starred version of a command. What really happens is that the unstarred command checks to see if there is a star as the first argument and passes control to different auxiliary macros accordingly, or simply executes two different sets of commands. So, to take a random example, we look at \endlargethispage and find that it is defined ...

12

Just as \makeatletter locally makes @ a letter you can locally make * a letter. \catcode\*=11 \makeatletter \let\oldequation*\equation* \let\equation*\@undefined \let\oldendequation*\endequation* \let\endequation*\@undefined \makeatother \catcode\*=12

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