# Tag Info

0

Two patchings to \@part (one for the entries in the ToC and the other for the headings in the document) will do the job; the fmtcount package was used to turn the Arabic number representation for the part counter to a ordinal string: \documentclass{book} \usepackage{xpatch} \usepackage{fmtcount} \makeatletter \xpatchcmd{\@part} ...

0


2

Ian Thompson's code is good, but you could add the check whether you can define a new length in the first place; calling, say, \deflen{textwidth}{6pt} would issue an error message at \newlength, but it would set \textwidth nonetheless. Since you are in a style file you don't need \makeatletter for @ commands, so you can do \newcommand{\deflen}[2]{% ...

8


1

The following example defines \chapterA with a range as chapter number. Also chapters inside the appendix are supported. Because of the longer numbers, the table of contents is adjusted accordingly. \documentclass{scrreprt} \let\savedthechapter\thechapter \let\orgchapter\chapter \renewcommand*{\chapter}{% \let\thechapter\savedthechapter \orgchapter } ...

4

One option using titlesec; the command \standardchapter produces a "normal" heading; \combinedchapter produces a heading in each the numbering has the form <number>.-- <number>+#1, where #1 is the integer in the mandatory argument: \documentclass{book} \usepackage{titlesec} \newcommand\standardchapter{% \titleformat{\chapter}[block] ...

3


6

Perhaps you like the ring to go below the tensor product symbol, but typography doesn't. Here's why: \documentclass{article} \usepackage{amsmath} \newcommand{\tens}[1]{% \mathbin{\mathop{\otimes}\limits_{#1}}% } \begin{document} Here is a tensor product $M\tens{R}N$, but note that it will have a very bad influence on the spacing of lines. Here is a ...

0

I post here is a supplemental test I made. I post it to demonstrate the effect of \setlength when it is inside or outside a group (a possible workaround to my problem that David Carlisle suggested in its first comment to my question). However, I prefer David Carlisle 's answer with \global. It allows to display and set the value within one single command ...

7

You need a global assignment for the effects to be seen outside the group: \documentclass{scrartcl} \usepackage{pbox,calc} \makeatletter \newcommand*{\strippt}[1]{\strip@pt#1} \makeatother \newlength{\pointsExo} \setlength{\pointsExo}{4pt} \newlength{\pointsSousTotal} \setlength{\pointsSousTotal}{0pt} \newlength{\souspointsExo} ...

4

Update The code below has been updated to use the new syntax for background. The updated syntax was provided by Gonzalo Medina to replace the code my original answer borrowed from this answer. See comments for history. I am not certain how to adapt the code directly because \part works a bit differently from \chapter as I understand it. However, it is ...

3

David has already explained why the nested \repeat command can't work and also why it's a bad idea to use the name \repeat. Here's a different definition, based on expl3: I'd say it's way easier, judge for yourself. \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_set_eq:NN \xrepeat \prg_replicate:nn \ExplSyntaxOff \begin{document} ...

6

You get ! Missing = inserted for \ifnum. because \repeat has \ifnum#1>\z@ so #1 has to expand to a number, but it is \repeat{2}{1} which includes many non expandable constructs such as \@repeat, \relax and \advance. Also although unrelated to the error in this fragment, it is a very bad idea to redefine \repeat as it is part of the basic \loop ...

1

Counters can only contain integer numbers. If you want to deal with real numbers you have to play with lengths. The following MWE uses lengths instead of counters (the internal macro \strip@pt is used to strip pt when printing the length): \documentclass{scrartcl} \usepackage{pbox,calc} \makeatletter \newcommand*{\strippt}[1]{\strip@pt#1} \makeatother ...

18


3

This might be done with pure expansion, but since you're using xstring it's not really necessary: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\mylist}{ m o } { \clist_clear:N \l_tmpa_clist \clist_map_inline:nn { #1 } { \clist_put_right:No \l_tmpa_clist { ##1 } } \IfNoValueTF{#2} { \l_tmpa_clist } { ...

2

Try the following: \documentclass{article} \usepackage{etoolbox} \makeatletter \def\ifemptyarg#1{% http://tex.stackexchange.com/a/58638/5764 \if\relax\detokenize{#1}\relax % H. Oberdiek \expandafter\@firstoftwo \else \expandafter\@secondoftwo \fi} \makeatother \providecommand{\listcomma}{} \newcommand{\mylist}[2][,]{% ...

4

Updated version: The first version of the code (see below) had one problem: if the box height was too big, then the signs will protrude their corresponding boxes; this can be solved choosing a maximum value for the length of the signs. The following code shows one such possibility; the length is (approximately) the minimum between the height of the box and ...

0

Thanks for the long explanation. It didn't solve the problem but answered the asked question about how to deal with log files. I had the suspicion that the macros are fine and that there are some chars too much or less in the main document. So I moved an extra \end{document} through my document to see when the error appears. It was that simple: Just one { ...

1

Too long for a comment. Typical reasons for "Runaway argument" errors are: A missing closing argument brace. A missing argument for a macro that confuses the internals of the macro. Bug. Example for a missing closing argument brace: \documentclass{article} \begin{document} Hello \textbf{World! \section{Foobar} \end{document} TeX complains: Runaway ...

1

Assuming you have a recent version of TeXcount (version 3), you can add more counters and use these to count words. %TC:newcounter mine My words %TC:macro \mytext [mine] Text inside \mytext{my macro} now gets counted separately. The syntax of newcounter is %TC:newcounter _name_ _description_ where the description may consist of several words (i.e. may ...

3

Your code will work if you just leave the \fill and \draw parts in the definition of \iround and move the interior titled code to the argument of tcolorbox: \documentclass{article} \usepackage[many]{tcolorbox} \usepackage{calc} \usetikzlibrary{calc} \definecolor{mp}{RGB}{240,240,240} % Farbe für + - \newlength{\bs}\setlength{\bs}{30pt} % Basislänge ...

3

Verbatim-like environments cannot be in the argument to another command. You can define, with the help of the fancyvrb package a new environment for writing out a file: \documentclass[]{article} \usepackage[autostyle]{csquotes} \usepackage{lipsum} \usepackage[backend=biber,doi=false,url=true,eprint=true,style=ieee]{biblatex} \usepackage[]{hyperref} ...

4


3

Karl has already shown you about forming a newenvironment using environ. I will point out some improvements to your tikzpicture code. Use tikzset instead of tikzstyle. No need of specifying ysep when you have already inner sep. No need of using minipage inside the node. You can specify text width= 0.85\textwidth, minimum width = 0.85\textwidth in node ...

6

With the help of \NewEnviron from the environ package \documentclass{article} \usepackage{tikz} \usepackage{environ} \NewEnviron{smallenvironment}{% \tikzstyle{mybox} = [draw=red, rectangle,inner sep=5pt, inner ysep=5pt]% \begin{center}% \begin{tikzpicture}% \node [mybox] (box){% ...

3

Your command is fragile (because of the use of \ifthenelse so needs \protect if used in a moving argument such as caption: \documentclass{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{caption} \usepackage{float} \usepackage{ifthen} \title{A caption test} \author{Some one} \date{\today} \begin{document} ...

7

The restriction of the AMS alignments that they may not be hidden behind command forms is documented on page 28 of the amsmath guide (texdoc amsmath ) Actually the restriction is better described in the technical notes (texdoc technote) as shown in the other answer. The names chosen here are particularly dangerous as using \def you lose the warning that you ...

10

The technote document explains why this kind of shorthand definitions will fail:

11

It grabs the content until the next brace (or group). For example: \def\foo#1#{«#1»} \starttext \foo random content {until braces} \stoptext gives

2

With xparse it's almost a one liner: \documentclass{article} \usepackage{imakeidx} \usepackage{xparse} \makeindex \NewDocumentCommand{\mindex}{ >{\SplitList{,}} m } {% \ProcessList{#1}{\index}% } \begin{document} x\mindex{keyword1, keyword2, keyword3, keyword1!keyword4} \printindex \end{document} Of course imakeidx is just for convenience; ...

3

Please try the following example if it fits your needs. I use \foreach statement from the pgffor/tikz/pgfplots package. %! *latex mal-index.tex \documentclass{article} \usepackage{pgffor} \usepackage{makeidx} \makeindex \def\multipleIndex#1{\foreach\entry in{#1}{\index{\entry}}} \begin{document} My first paragraph. \index{test1}% \index{test2}% ...

3

You can accomplish something similar to this by creating TikZ styles called s and .: \documentclass[margin=10pt,convert]{standalone} \usepackage{tikz-cd} \tikzset{commutative diagrams/.cd, s/.style = {swap}, ./.style = {dotted}, s./.style = {s,.} } \newcommand{\A}{\ar} \begin{document} % Two different keys, separated by commas: ...

-4

I would suggest the following: \def \bm {\begin{matrix}} \def \em {\end{matrix}} So that you just need to type \bm instead of \begin{matrix} minimal code \documentclass{article} \usepackage{amsmath} \def \bm {\begin{matrix}} \def \em {\end{matrix}} \begin{document} $\bm 1 & 2 \\ 3 & 4 \em$ \end{document}

6

I use emacs with AUCTeX and Ctrl-c Ctrl-e will enter the matching pairs automatically. I'm sure vim will have a command that does likewise.

15

Just delete the unnecessary braces in your definition. \documentclass{article} \usepackage{amsmath} \newcommand{\matx}[1]{\begin{matrix}#1\end{matrix}} \begin{document} $\matx{ 1 & 2 \\ 3 & 4 }$ \end{document}

8

The declaration \newcommand{\mc}{\mc} ultimately becomes, in terms of TeX primitives, \long\def\mc{\mc} where \long is irrelevant for the case in discussion. You have to consider that TeX doesn't interpret in any way the replacement text of a macro when it stores the definition for it. It's a necessary feature, because when we expand a macro, we want ...

4

It is possible to define a macro in terms of itself. As mentioned in the comments, you need to be careful. The problem with \newcommand\mc{\mc} does not occur when it's defined but when you first try to use it, at which point, if left as is, it will recursively call itself. Sometimes this is the behavior you want. But sometimes you want something else, ...

4

I don't really understand why you'd want long blocks of text sticking out in the margin. However, here's a way; I avoided underscore for a safer method accomplishing the same result. \documentclass{article} \usepackage[T1]{fontenc} % better underscore \usepackage{amsmath} \usepackage[htt]{hyphenat} \newcommand\code[1]{\texttt{#1}} %% This code substitutes ...

3

You can avoid using many arguments. Here's an implementation of your \cmd where you specify the arguments as a comma separated list; with \selectorder you can decide what order is used in the output. Note that \cmd will happily accept any number of items in the list; all you need is to specify the correct number of columns in the tabular and precede it with ...

5

One way would be to use pythontex package: \documentclass{article} \usepackage{pythontex} \newcommand\insPython[1]{ \begin{figure} \centering \pyc{import os; print (r"#1")} \end{figure} } \begin{document} \insPython{bla bla} \end{document} You need to run pdflatex then pythontex (or pythontex.exe) and pdflatex again. Somehow I needed to use Python 3 ...

12

Cells inside a tabular form groups, so in your example the commands defined by \cmd are not available starting with the second cell. Solution: Use \gdef instead of \def in the definition of \cmd. \documentclass{article} \newcommand{\cmd}[5]{% \gdef\tA{#1}% \gdef\tB{#2}% \gdef\tC{#3}% \gdef\tD{#4}% \gdef\tE{#5}% \tA & \tB & \tC & ...

2

Adding the option fragile to the frame allows a correct processing: \documentclass{beamer} \usepackage{lmodern} \usepackage{filecontents} % For tables \usepackage{pgfplotstable} \usepackage{booktabs} \usepackage{array} \pgfplotsset{compat=1.9} \pgfplotstableset{ %font={\small}, empty cells with={--}, % replace empty cells with ’--’ every ...

5

\UrlLeft and \UrlRight can be used for the purpose of adding angle brackets, see section "6 Yet more flexibility" url's documentation. Example: \documentclass{article} \usepackage{url} \DeclareUrlCommand\url{% \def\UrlLeft{\langle}% \def\UrlRight{\rangle}% } \begin{document} \url{http://www.example.org/} \end{document} Remarks: \langle and ...

1

Not sure I understand the requirements, but here is some custom \verb more or less extracted from some code I needed on another occasion. As the alltt environment from the alltt package it treats \, {, and } normally. Additionally it treats spaces as in regular tex source, thus allowing line breaks. And this is an inline, not display "environment". To be ...

3

Please always post complete documents that show the error, and also show the exact error generated by TeX (the format you showed is not a tex error). \documentclass{article} \usepackage{amsmath} \usepackage[utf8]{inputenc} \begin{document} \label{eq:e211} I_C = C \dfrac{dv_c}{dt} \xRightarrow{Em regime estacionário} I=I_C=C.0=0 ...

3

LyX uses LaTeX as the backend, so in principle you can use any LaTeX macro in LyX. For your case, you can go to Document --> Settings --> LaTeX preamble, and add your \newcommand there. To use it in a document just type \from, but note that this only works in math mode.

6

While Werner answers the question posted, I would recommend an approach that uses mdfdefinestyle instead when talking about options specifically for the mdframed environment. Define each of the collection of styles in an\mdfdefinestyle, and then combine them as desired: \newmdtheoremenv[style=myopts,style=options1]{env1}{Environment 1} ...

5

This is a simple replacement tool at a Lua level. Everything written in \parseme is a target for replacements, but the TeX commands are not expanded and we can hide a portion of text from replacement procedure. The replacements are stored in a simple Lua table, the first column contains the searched terms and the second column contains their replacements. ...

17

This is a good thing, since it promotes consistency. However, your key-value argument needs to be expanded before it can be properly assigned using key-value pairs. For this you have at least two options: Explicitly insert \expandafters to jump over the construction until you reach the optional argument(s): ...

Top 50 recent answers are included