# Tag Info

3

An explicit number can be expanded without changing it and the unwanted command sequence can be redefined to vanish itself, when expanded: % Setup \makeatletter \newif\ifintheway \def\@citeb{foobar} \def\bfoobar{\inthewayfalse 17} % Extract the number from \csname b\@citeb\endcsname % and store it in the macro \mynumber \begingroup ...

0


4

\documentclass[11pt,spanish,a4paper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} OK so far except that theses usually have chapters so book or report might be preferable. \setlength{\parskip}{2ex} \setlength{\parindent}{0pt} Better to use parskip. \usepackage{textcomp} \usepackage{url} \usepackage{graphicx} \usepackage{setspace} ...

4


0

When you \def\sum{\sum\limits}, you tell TeX that \sum expands to the two tokens \sum and \limits. This \sum then expands to \sum\limits, expanding to \sum\sum\limits, expanding to \sum\sum\sum\limits, ad nauseam. Using the different name will resolve the issue, but I encourage you to not do this. There are many instances where such a shortcut will break ...

3

To collect your label in the "Tree" interface, follow these steps: Show the "Options Interface" (Options -> Options Interface) Double-click the "Tree" item (Tree.ini gets opened) Locate the lines BRANCH="Labels-TeX" BRANCH_CAPTION="Labels (#)" // Change Mode from TeX to ? to disable this item BRANCH_MODE_FILTER="TeX|DTX;INS;STY;AUX" ...

0

What you want is a macro. Wikibooks has excellent tutorial on the topic. As for the code environment, use the listings package: Wikibooks, CTAN. Here is a quick example of what you can do. The \newcommands there make three, well, new commands: \compbox, \compline, and \comp. \documentclass[a4paper]{article} \usepackage{fancybox} \usepackage{listings} ...

3

Parameters can be used only in the scope of a macro definition, so your ##2 in the file is meaningless. \begin{filecontents}{test-disputeUS} \section{Governing law. Arbitration} \label{sec:dispute} The parties agree that the Agreement shall be governed by the laws of the State of \ifstr{\control}{DE}{Delaware}{New York}, USA, without giving effect to its ...

3

You have to use suffix and not expr: def anchors(suffix p) = pair p.n, p.e, p.s, p.w; p.n := .5(ulcorner p + urcorner p); p.e := .5(urcorner p + lrcorner p); p.s := .5(llcorner p + lrcorner p); p.w := .5(ulcorner p + llcorner p); enddef; path b; b := unitsquare scaled 1pt; anchors(b); show b.n; show b.e; show b.s; show b.w; end This outputs ...

3

5

A macro that supports complex ranges must use the full force of expl3. Here's a possible solution: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\range}{ m m } { \cashner_range:nn { #1 } { #2 } } \tl_new:N \l__cashner_range_input_tl \seq_new:N \l__cashner_range_input_seq \bool_new:N \l__cashner_range_multi_bool ...

1

Have you tried the ifmtarg package? It provides the macro \@ifmtarg{<arg>}{<Code for arg empty>} {<Code for arg not empty>} Use texdoc ifmtarg for the documentation.

6

It's quite easy with xparse: \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\range}{ m >{\SplitArgument{1}{ }}m } {% \dorange{#1}#2% } \NewDocumentCommand{\dorange}{ m m m } {% \IfNoValueTF{#3}{#1~#2}{#1[]~#2--#3}% } \NewDocumentCommand{\defineabbreviation}{ m m m } {% \NewDocumentCommand{#1}{o}{\IfNoValueTF{##1}{#2}{#3}}% ...

4

The code inside siunitx (v2) uses a loop over each token in the input before comparing this to the various lists of possible 'number parts'. As that process cannot make assumptions about the nature of the tokens and as it covers a variety of input forms, it's rather complex. I'm currently re-writing it all to be more efficient and clear but the need to work ...

5

You can use a \romannumeral trick: \if\relax\detokenize\expandafter{\romannumeral-\Q#1}\relax The missing space after \Q will trigger expansion of #1 (after macro substitution, of course). Since this expansion ends at the first unexpandable token, this should be what you want. However a leading space will be ignored. \def\notempty{\relax} ...

6

\documentclass{article} \usepackage[T1]{fontenc} \def\foo#1{\par \texttt{<\detokenize{#1}>} \expandafter\if\relax\detokenize\expandafter{\romannumeral0#1}\relax \if X#1X% empty\else not empty\fi \else not empty\fi} \begin{document} \foo{} \foo{ } \foo{\empty} \foo{{}} \foo{\sqrt} \foo{\csname @gobble\endcsname{hello}} \end{document}

1

The two-line solution which uses only TeX primitives follows: \def\sdef#1{\expandafter\def\csname#1\endcsname} \def\mkMac#1{\sdef{the#1}{The macro #1}\sdef{#1}##1{\sdef{the#1}{##1}}} \mkMac{affilation} \affilation{University} Welcome to \theaffilation

1

You can define a new template based on the frame number one for footline: \documentclass[compress,final]{beamer} \usepackage{ragged2e} % for justifying \usepackage{lipsum} % for random texts \usepackage{geometry} \geometry{lmargin=.5cm, rmargin=.5cm} ...

7

They mean something like \documentclass[graybox,envcountchap,sectrefs]{svmono} but with smallextended in the options between [] and perhaps a different class than svmono depending on your requirements. Springer have extensive documentation and examples in a zip file you can download from ...

0

LaTeX defines a short interface similar to that provided by etoolbox in the form of \@namedef (from latex.ltx): \def\@namedef#1{\expandafter\def\csname #1\endcsname} Here is a minimal example showing the usage: \documentclass{article} \makeatletter \newcommand*{\mkMac}[1]{% \@namedef{the#1}{The macro #1}% \@namedef{#1}##1{\@namedef{the#1}{##1}}} ...

1

The best way to define new macros is to use the etoolboxs \csdef: Notes: Note that \aa is already defined., so you should use an alternate name. As \csdef won't issue an error in that case, I have added a test to make sure that the code issues an error if you attempt to redefine an existing macro. You can also use \csname...\endcsname to build names of ...

5

There are a few errors in the definition of \remainder and \othermacro: a \newcount declaration mustn't go inside them, because this would waste a counter at each call. Also a space after #2 is significant and it means that TeX looks for a space after the second argument, raising an error if it doesn't find one and taking as second argument everything that ...

8

The requirement is easy to fulfill: \documentclass{article} \usepackage[nopar]{lipsum} % just for the example \newcommand{\verset}[1][]{\stepcounter{verset}% \textbf{\theverset. \if\relax\detokenize{#1}\relax \else #1 \fi }% } \newcounter{verset} \begin{document} \lipsum[1] \verset \lipsum[2] \verset[Description] \lipsum[3] ...

9

Using Styles (Recommend Approach): You should use tikzset to define your own styles. Below, I defined My Axis Style for your axis style, and My Plot Style for your plot: Notes: Removing the blank line between the two sub figures will put the figures next to each other. This is the similar to the behavior in normal text paragraphs where a blank line ...

3

Run with pdflatex --shell-escape ... \documentclass{article} \usepackage[crop=off]{auto-pst-pdf} \usepackage{pst-barcode} \begin{document} \pspicture(1in,1in)\psbarcode{\jobname}{}{qrcode}\endpspicture \qquad \pspicture(0.5in,0.5in)\psbarcode{\jobname}{format=micro}{qrcode} \endpspicture \end{document}

8

The macro \getfromjobname is not “fully expandable”, due to usage of \ifthen, so it can't be used in the argument to \qrcode. Using directly \gettwofromjobname works. If I name the file kinda-hanta.tex and modify it to be \documentclass{article} \usepackage{qrcode} \usepackage{varsfromjobname} \begin{document} \def\foo{hanta}% ...

7

macro names do not need to be allocated, you can have (up to implementation defined limits) arbitrarily many csnames with macro definitions. But classic TeX only has 256 registers of each type (extended to 32768 in etex) so length (skip) registers need to be allocated from a fixed pool with separate commands for allocating a register (which just reserves the ...

1

\newlength is defined as a \skip, i.e. register provided also to calculations (\newlength reserves a new skip, \setlength sets its value), while \newcommand in this case would be only a string.

5

Please always post complete documents, as below, not just fragments. If I start with \documentclass{report} \begin{document} \newcommand{\met}{\cancel{\it{E}}_{T}} \chapter{\met} \end{document} I get ! Undefined control sequence. \met ->\cancel so change to \documentclass{report} \usepackage{cancel} \begin{document} ...

1

\newcommand{\stringnumber}[2]{% \ifnum #2>0 #1% \stringnumber{#1}{\numexpr#2-1} \fi } The previous code, when the number of requested repetitions is high, generates very long token lists. Here's a better implementation that avoids the problem. \documentclass{article} % it's better if the number of repetitions is first ...

4


10

this version is not expandable but it doesn't need any terminator, it just gobbles up as far as the end of the number. It is restricted to integers that fit in a tex count register. \newcount\ca \newcount\cb \def\p#1{% \def\digitone{}% \ifx+#1\def\sign{#1}\else \ifx-#1\def\sign{#1}\else \def\sign{}\def\digitone{#1}\fi\fi \afterassignment\n\ca=1\digitone} ...

4

\documentclass{article} \usepackage{xparse} \usepackage{graphicx} \DeclareDocumentCommand{\zmatrix}{ O{RowName} O{ColumnName} mm}{% \rotatebox[origin=c]{90}{\hspace{-20pt}#1}% \kern7pt \begin{tabular}{|c|*{#3}{c|}} \multicolumn{1}{c}{} &\multicolumn{#3}{c}{#2} \\\cline{2-\numexpr#3+1\relax} \multicolumn{1}{c|}{} \mhead{1}{#3}\\\hline \mrow{1}{#3}{#4} ...

10

EDITED to seamlessly handle dots and/or commas as the decimal separator. REEDITED to provide error checking. The error handler works by pre-processing the string and removing "numerically valid" tokens from it (any numeral, leading + or -, and a single . or ,). If the processed string is not a null string at the end of this error-checking process, then it ...

1

Two remarks : \isin seems impossible to put inside path command. So you have to do (as proposed by @jfbu) : {\ifthenelse{...}{\path (right) edge (\name);} {\path (left) edge (\name);}} to be able to use \isin{\name}{#2} you have to expand \name befor to pass it to \isin like this \expandafter\isin\name{#2} so finaly you can ...

0


4

Probably a better solution is using small caps: \documentclass{article} \begin{document} \def\Hi{\textsc{Hi}} And now you can write \Hi\ and \large\Hi\ and \Large\Hi\ and \LARGE\Hi \ and \huge\Hi\ and \Huge\Hi. \end{document}

4

\small is a font switch - it does not take an argument. It makes everything afterwards small until it is cancelled by another size command or the document or group ends. Try H{\small I} The {} will limit the effects of the switch to just what is contained within them. (They make a group.)

0

This web helped me to decide, it isnt complex enough but it may guide one http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Electronics/Programs

9

It is sort of legal latex but clearly not "good latex style". \noindent shouldn't normaly be used, and \vskip shouldn't be used. (\vspace) Normally within a document one would use a blank line rather than \par (\par is more use within macro definitions where a blank line often looks less convenient, as you may wish to indent code). LaTeX counters like a ...

5

tex parsing is controlled by "catcodes" (\catcode) the catcode of any character is changeable, but control sequence names can be any number of catcode 11 characters (letters) or a single non-letter so \"o for example is \"{o} not a command called "o digits are non-letters so you can have \1 but not \a1. It is possible to make digits letters by making them ...

8

\number and \the are similar on a count register. \the may be applied to more types, such as \the\dimen0 or \the\everypar or \the\font Using \number on those cases is either an error or (in the first case) casts the dimen to a number, taking its value is sp units.

Top 50 recent answers are included