Tag Info

New answers tagged

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

Thanks to @egreg's answer, I finally got to an example which demonstrates how to patch and \show a \newcommand, which otherwise has some protection (see Are commands defined by \newcommand[.][.]{.} robust?). The problem is, when you \show a \newcommand, you just get something like "\@protected@testopt \mycmd \\mycmd {}.", not the "real" internals of the ...


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

\# \$ \% \& \~ \_ \^ \{ \} are very different types of commands, \% makes a percent but \^ does not make ^ it is a command that takes an argument \^{a} constructing accented letters. You can use \detokenize{@Model.ReportTitle} then you basically only need to quote \( \} and \% to ensure that the construct has balanced braces. and add ...


2

You can use the \vspace*{length} command to write to the same line multiple times. Combine this with the \baselineskip length to jump several lines up or down. Additionally, change \baselineskip locally to make room for sub-line legends: \documentclass{article} \pagestyle{empty} \parindent0pt \begin{document} \bgroup % Double line space (or use setspace ...


3

Although in older posts of mine, I was reluctant to recommend the use of LuaLaTeX, the code has now matured enough and the LuaTeX Team is doing such a great job, that I would heartily recommend that any "thesis class" seriously considers using LuaLaTeX. Thesis templates are about enforcing styles and parsing is one of the stengths of Lua. As you wish to ...


4

The implementation is not the best, but just to see it can be done: \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\macroa}{ >{\SplitArgument{1}{,}}m } {% \processtwo#1% } \NewDocumentCommand{\processtwo}{ m m } {% \IfNoValueTF{#2} {% \semicolonfalse #1, % } {% \semicolontrue #1 \textbf{\textit{#2}}% ...


2

What you think works doesn't do it. By chance you have selected two words without depth, while # has it. Try with: \documentclass{article} \usepackage{tikz} \newcommand{\mkTikzCoord}[2]{% \tikz[remember picture, baseline=(#1.base)]{\node [inner sep=0, outer sep=0, text depth=.25ex, text height=1.5ex] (#1) {#2};}% } \begin{document} Some text where I ...


3

You are confusing latex with the square backets for the optional arguments. When latex sees \TestA[\TestB[111]] it thinks that the optional argument for \TestA is \TestB[111. Now it tries to evaluate this expression and gets confused because \TestB is not conforming to syntax. To fix this you need to put brackets around the optional argument to \TestA: ...


1

You can use \edef\sum in this way: \edef\sum{\mathchar\the\sum\limits} ... A summation $\sum_{i=1}^{n} a_{n}$ ...


0

As \int is defined \intop\nolimits, you have at least two natural ways of obtaining limits placed where you want: \documentclass{article} \begin{document} \[ \int_{0}^{1}1\,dx \] \def\Int{\int\limits} \[ \Int_{0}^{1}1\,dx \] \let\uglyamericanint\int \def\int{\intop\limits} \[ \int_{0}^{1}1\,dx \] \end{document} (I have no tools to crop the ...


3

This is as easy as \documentclass{article} \usepackage{amsmath} \makeatletter \renewcommand{\slimits@}{\limits} \renewcommand{\ilimits@}{\limits} \makeatother \begin{document} A summation $\sum_{i=1}^{n} a_{n}$ and an integral \[ \int_{0}^{1} x^2\,dx \] also inline: $\int_{0}^{1} x^2\,dx$ \end{document} However the result is typographically terrible. ...


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

Behold my psychic power! Use \cslet to set \answer1 etc. to the current definition of \answer, not answer itself. \documentclass{article} \usepackage{etoolbox} \newcounter{a} \setcounter{a}{0} \newcommand\setans[2]{% \csdef{answer#1}{#2}} \newcommand\addans[1]{% \stepcounter{a}% \cslet{answer\thea}{#1}} % <--- Not \csdef! ...


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

multido has a simple interface for replication: \documentclass{article} \usepackage{multido} \newcommand{\cmd}{-x-} \newcommand{\Repeat}{\multido{\i=1+1}} \begin{document} \Repeat{6}{\cmd} \end{document}


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

Przemysław Scherwentke has already given an arguably better answer (both in looks and because it scales well), but in case you wanted exactly that size difference between the two characters, \newcommand{\HI}{H{\small I}\ } will allow you to insert that anywhere with just \HI. \documentclass{article} \newcommand{\HI}{H{\small I}\ } \begin{document} ...


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