# Tag Info

1

\mathcode\.="8000 \begingroup \catcode\.=\active \gdef.{\mathord{,}} \endgroup Defines it to be “math active”, and you can change the definition whenever you want. You need to write 2.71, and the output will be as desired (in my example 2,71 with no space). As @wipet says, it's much more easier: \mathcode\.=\,

2

Well, if you only want to suppress the space, you can write $12{,}34$. This is what I mostly do if I feel that siunitx is an overkill (I'm a mathematician, I rarely work with units, however, I do work with floats).

7

You have two well-established options: Load the siunitx package with the option output-decimal-marker={,}, and then write \num{123,456}. The option to treat , as the decimal marker carries over to numbers typeset in tables if the package's S column type is specified. \documentclass{article} \usepackage[output-decimal-marker={,}]{siunitx} ...

8


4

Here are two versions that give slightly different behavior, depending on what you really seek. \documentclass{article} \usepackage[T1]{fontenc} \newcommand{\mytest}[1]{\texttt{#1}} \def\mydump#1{\detokenize\expandafter{#1}} \def\mydumplit#1{\detokenize{#1}} \begin{document} \mydump{\mytest{Hello World}} \mydumplit{\mytest{Hello World}} \end{document} ...

4

Using an ampersand & inside a macro is not advised since it ends a group. Below is a workaround that replaces ampersands by control sequences, and then \& evaluates to the ampersand retro-actively. LaTeX then already evaluated the structure of your matrix to evaluate where the groups end afterwards. That way the structure defined by your macro ...

5

The syntax is not \ifx<firsttoken><secondtoken>{<true code>}\else{<false code>}\fi The correct one is \ifx<firsttoken><secondtoken><true code>\else<false code>\fi So you can remove the braces around {#1} and {#2} (which, in the case of \usepackage{fontspec} act as a group delimiter).

2

Files that are not part of the distribution should go to the texmf-local root, organised according to TDS. More precisely, in the present case, you should create in texmf-local the following directories: 1) texmf-local\doc\latex\statisticsjournal\ (or springerjournals, depending on whether the the files are specific to this journal or not), in which you ...

1

No need of re-installing anything. Go to Options → Execution Modes. In the window that opens correct the paths in TeX System, Ghostscript (if you want), and PATH tabs. Finally you may check your system using Diagnosis tab in the same window.

3

The \nobreak macro prevents a break after the current material. That's standard for headings amongst other places: no line break should come between the heading and the following text. In LaTeX, a common construct is \section{Some section} \label{sec:important} Text here Using just a \nobreak inside \section, the break would keep the label with the ...

5

The command \setkeys{METest}{wide=false} sets this key to false, so you have no chance to provide another value. \setkey should be inside the macro using the syntax \setkeys{METest}{wide=false,#1}, such that a possible override within #1 of the key value is handled. You can specify a default value to an option, using the [] syntax as I have done with the ...

0

I guess you installed first WinEdt and then MiKTeX. Better and easier is it to install first MiKTeX and then WinEdt. The advantage is now, that WinEdt is able to see that you have MiKTeX running and can prepare a good configuration by its own. In your case I think the best way is to deinstall WinEdt, reboot your computer (important!), Install WinEdt ...

2

Some environments that do 'clever' things don't like shorthand macros of this type. Another example is the align environment from the amsmath package. Shamelessly borrowing from the technical details for amsmath, I suggest the following. \documentclass{beamer} \long\def\bslide#1\eslide{\begin{frame}{xxx}#1\end{frame}} \begin{document} \bslide This is a nice ...

2

Please, use csvsimple version 1.12 (2014/07/14) (or newer). In my code, I made a helper macro \commandThreeX which is used to get rid of the semicolon at the end of the input lines. The rest is quite straigtforward using \csvreader: \begin{filecontents*}{example.csv} foo,bar,baz; zip,boom,bang; \end{filecontents*} \documentclass{article} ...

10

The code presumably isn't intended to be read by a novice LaTeX user but... \def\@dottedtocline#1#2#3#4#5{% a macro with 5 arguments \ifnum #1>\c@tocdepth tt\else If #1 is deeper than the limit for the table of contents depth typeset tt (a typo??) Otherwise \vskip \z@ \@plus.2\p@ add a small vertical space between 0 and .2pt ...

3

Update Better Version for the lua file, with different probabilies n = math.random(1,6) if n == 6 then tex.sprint("foo1") elseif n >= 4 then tex.sprint("foo2") else tex.sprint("foo3") end (example probabilites: 1/6 => foo1 1/3 => foo2 1/2 => foo3 ) Another easier solution with the compromise of fewer options (and only if using Lualatex): set a new ...

13

You can define the macro by specifying a relative frequency: \documentclass{article} \usepackage{xparse} \input{random} \ExplSyntaxOn % alias \setrannum to an expl3 function \cs_set_eq:NN \benutzer_set_rannum:Nnn \setrannum \NewDocumentCommand{\newrandomcommand}{mm} {% #1 is the macro name, #2 is the data \cs_if_exist:cTF { #1 } { ERROR! } ...

11

This is a preliminary version. The accounting of how much a word has been called so far is not done so far. I will update the solution... Just define a word pool list with \NewWordPool{poolname}{WordA,WordB,{SentenceA}} and say \pickuprandomword{\poolname} The pool name is just like a macro name, but without \ character \documentclass{article} ...

4

It's an expansion problem: when the key is set, no expansion is performed, so you have to pass the expanded \pb@language macro: \documentclass{article} \usepackage{listingsutf8} \usepackage{xkeyval} \makeatletter \define@key{MESourceFile}{language}{\def\pb@language{#1}} \setkeys{MESourceFile}{language={[ANSI]C}} \newcommand\MESourceFile[4][]{% ...

2

In short, the explanation is that in several contexts: \def\foo{\ifmmode alpha\else beta\fi} ...$\foo ...$ ... it won't yet be visible that we're in math mode when \foo is invoked. But after \relax, then \ifmmode will then be able to see that we are in math mode. Knowing the explanation, I was then able to find these further discussions of it on this ...

6

There seem to be few advantages in doing this. Unless you take more precautions the \ifmmode will take the wrong choice at the start of any array or alignment cell, that could be fixed using a suitable \protected\def or \DeclareRobustCommand or simply starting the definition with \relax but even then there are few if any cases where the text character ...

2

Thanks to the inspiration from David's and Joseph's use of #1 as placeholder for the loop counter, I was able to improve the implementation that I've given in the question. I'll post it here mostly as a learning exercise for anyone who happens to have a similar use case. This version only expands the loop counter and leaves all other tokens alone, removing ...

2

Your example isn't usable however the default bold fonts in the default Computer Modern font setup are bold extended (bx). Computer Modern also has a bold unextended series (b) which may be selected as shown. \documentclass{article} \begin{document} abcdefghi \textbf{abcdefghi} {\fontseries{b}\selectfont abcdefghi} \end{document}

4

The trailing space is due to the end-of-line characters in the input file. The simplest workaround is to remove it altogether by setting (temporarily) \endlinechar=-1 Here's a full example, where I stripped off the irrelevant things, but added a safety measure for the underscore (you possibly don't need it). I also changed the input file to \jobname.dat ...

7

There are a number of possible approaches to doing this without the complexity: I'll cover a couple using expl3. First, if you don't mind keeping things non-expandable then you could do something like \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_new_protected:Npn \For #1#2#3#4 { \int_step_inline:nnnn {#1} {#2} {#3 - 1} {#4} } ...

6

This loop just uses expansion. In order to use #1 as the loop counter it is easiest to define it anew each time, if you didn't want access to the counter you could more easily use \myrepeat{5}{some code} Note i didn't use \repeat as that name is taken in the existing \loop syntax. \documentclass{article} \def\myrepeat#1{\ifnum#1=0 ...

3

This is an explanation of the problem rather than a full solution. As Joseph Wright suggested this problem would be much easier to understand with a proper minimal working example. In fact, if you cut down to a MWE then it becomes clear what the problem is: as one might suspect, the xparse package is completely innocent. Here is (close to) a MWE. To save ...

5

You can use xparse package. It provides variuos options for declaring new environments: \DeclareDocumentEnvironment \NewDocumentEnvironment \RenewDocumentEnvironment \ProvideDocumentEnvironment These have the syntax \DeclareDocumentEnvironment {<environment>} {<arg spec>} {<start code>} {<end code>} Futher, to check whether the ...

4

\begin{figure} doesn't expand the optional argument; when expansion happens it's too late. \documentclass[10pt,a4paper]{article} \usepackage{keyval} \usepackage[demo]{graphicx}% draft is just for the example \makeatletter \define@key{image}{pos}{\def\i@pos{#1}} % define key-val \setkeys{image}{pos=!htbp} % set default \newcommand{\image}[2][]{% ...

4

\documentclass{article} \newcounter{spacenumber} {\catcode\ =\active\relax\gdef {\space\stepcounter{spacenumber}}} \begin{document} \begingroup \setcounter{spacenumber}{0} \obeyspaces% This is an example. \thespacenumber \endgroup \end{document} As egreg says, a space doesn't call \space command, so in your example the number of spacenumber is obviously ...

5

$A_\frac{a}{bc}$ works because _ does expansion in order to find a left brace, which may also be implicit. Thus the expansion of \frac is pursued all the way, since the usual definition is % latex.ltx, line 4260: \def\frac#1#2{{\begingroup#1\endgroup\over#2}} and so the { before \begingroup is scanned when the arguments have already been absorbed. This ...

4

There is another part of the original question: how to map \Open and \Close to the Unicode characters ❴❵ U+2774 and U+2775. If you are using XeTeX or LuaTeX then you can do: \catcode^^^^2774=13 \let^^^^2774=\Open \catcode`^^^^2775=13 \let^^^^2775=\Close If you are using pdfTeX with encTeX activated (by -enc option when format was generated) then you ...

10

Many people set up their editor to do such things automatically. Personally, I use snippets inside vim, which I highly recommend, for such things. For example, to write a tikzpicture environment I just type tikz and then hit <tab>. This inserts the full environment and it is much faster than your two shortcuts. There are similar tools for most editors. ...

0

@ECHO OFF SETLOCAL SET "sourcedir=D:\files\" SET /p mask="Which .tex-files?" PUSHD "%sourcedir%" FOR /f "tokens=1*delims=" %%a IN ( 'dir /b /a-d "%mask%*.tex" ' ) DO ( pdflatex.exe -interaction=nonstopmode --shell-escape "%%a" any other parameters perhaps containing "%%~na" ) POPD GOTO :EOF Full credit goes to Magoo, I just added the parameters ...

3

You have been warned! I know, many readers will regard this as a comment and not an answer, but the message seems too important to bury it in the digital massgrave of comments below the question: Such a macro \Close obviously may cause very strange effects, while making it impossible to find the cause. Beginners who have troubles with missing \end{some ...

9

I have said that you are inclined to plain TeX code. But your question seemed me to be interesting. So, I tried to do something despite this is LaTeX problem. You can start with experimenting with my code: \newcount\openLnum \newtoks\currtext \def\Open{\begingroup\let\bgroup=\relax \let\egroup=\relax \expandafter\checkbracesJ\autobracelist\end ...

4

A blank line is converted to \par, which is illegal in align and all math display environment. There are also some other glitches in your code: \documentclass[12pt]{article} \usepackage{amssymb} \usepackage{amsthm} \usepackage{mathtools} \newcommand{\mfunction}[4]{% \ifnum#4=0\relax M_{#1_{#2,#3}}% \else M_{#1_{#2,#3}^{k}}% \fi } ...

2

Delete the blank line after \def \lnum{#4}.

4

I can show the plain TeX solution of this problem for the sake of completeness. \def\separeparts#1{\def\firstpart{}\def\listchars{0123456789.}\separepartsA#1\end} \def\separepartsA#1{\isinlist{+-}#1% \iftrue \def\firstpart{#1}\expandafter\separepartsB \else \def\next{\separepartsB#1}\expandafter\next \fi } ...

0

Make a exclusive directory for pictures and load in the main document with the command \graphicspath{{./pictures/}} of the package graphics(x). Create a batch file like @echo off echo "Processing images ..." for %%i in (./*.tex) do pdflatex -interaction=nonstopmode %%i echo "Deleting auxiliary files ..." for %%i in (./*.aux) do del %%i echo "Deleting log ...

5

Just for completeness, here's an implementation using expl3: \documentclass{book} \usepackage{xparse} \usepackage{blindtext} \usepackage{xcolor} \usepackage{totcount} \ExplSyntaxOn \NewDocumentCommand{\DeclareAssociatedCounters}{mm} { \hupfer_declareassociatedcounters:nn { #1 } { #2 } } \NewDocumentCommand{\AddAssociatedCounters}{mm} { ...

3

You can define \scatterplotwidth to behave like a dimension parameter that loads a fraction of the current \linewidth by \newcommand{\scatterplotwidth}{\dimexpr0.5\linewidth\relax} Then \scatterplotwidth will be legal anywhere a length is needed, for instance in \includegraphics[width=0.9\scatterplotwidth]{myfig} By the way, the suggested ...

4


5

As egreg stated: the LaTeX kernel does not provide such a feature and perhaps there is other package doing this feature, so I have decided to provide a small package, being uploaded to CTAN and perhaps available soon. The assoccnt.sty file \NeedsTeXFormat{LaTeX2e}% \ProvidesPackage{assoccnt}[2014/08/13 v0.2 -- Associate counters stepping]% %%% %% License: ...

8

You can't define the *-variant with \newcommand{\NBR*}, that's all. The working version with \NewDocumentCommand has spurious spaces: you need to protect some end-of-lines. \NewDocumentCommand \NBR {s m} {% \IfBooleanTF{#1} {NBR #2} {NBR #2\cite{NBR#2}}% } No % is needed at the end of lines 3 and 4, because \IfBooleanTF has three arguments and ...

13

There are several approaches you can take. The easiest approach is to use xparse Then you can define a command as \documentclass{article} \usepackage{xparse} \NewDocumentCommand{\mycommand}{ mO{a} }{#2 \rightarrow #1} \pagestyle{empty} \begin{document} $\mycommand{A}$ vs $\mycommand{A}[b]$ \end{document} Alternatively you can use \def and ...

4

The documentation for mtpro2 makes it clear that \PARENS is a command taking one argument \PARENS{\frac{x}{y}} It's unsurprising that if you use it as an environment odd things happen (here, it grabs \frac but not the arguments to \frac, then problems arise as \frac looks for two arguments and fails to find them).

4

You can use \ensurebalanced macro for another types of parens by the following way: \def\macro(#1){\ensurebalanced()\macroA{#1}} \def\macroA#1{the "#1" is balanced here in () meaning} \macro(abc(de(f))g(hi)) % prints: the "abc(de(f))g(hi)" is balanced here in () meaning. Or your example: \def\args(#1){\ensurebalanced(){\fence()}{#1}} My macro ...

16

In LISP, it returns the first element of a list or a pair. In LaTeX, its definition is \def\@car#1#2\@nil{#1} (defined right before \def\@cdr#1#2\@nil{#2}), and it is defined in LaTeX core (latex.ltx). The origins of the word come from the architecture of some early IBM computers.

8

You have \args(bar\args(baz)) so the argument to the outer \args is bar\args(baz as it stops at the first ) you want \args({bar\args(baz)}) in the \foo example, the arguments are interpreted the same way, but it accidentally works. for the outer \foo '#1 is bar\foo(baz so that expands to (bar\foo(baz) then the inner \foo expands to ...

Top 50 recent answers are included