# Tag Info

1

The definition of \ressubheading contained in the CV template file cv_temp.tex: \newcommand{\ressubheading}[4]{ \begin{tabular*}{6.5in}{l@{\cftdotfill{\cftsecdotsep}\extracolsep{\fill}}r} \textbf{#1} & #2 \\ \textit{#3} & \textit{#4} \\ \end{tabular*}\vspace{-6pt}} requires the array package, so simply load it in the preamble: ...

1

outlines takes the styles from enumerate labels. You can change these with the help of enumitem package. \documentclass[a4paper, 12pt]{scrartcl} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[italian]{babel} \usepackage{amssymb, amsmath, amsfonts} \usepackage{outlines} \usepackage{enumitem} \setlist[enumerate,2]{label=\roman*)} ...

5

You could put a \hypertarget in every call of \AAA, where the name uses a counter. Afterwards you can reference it by \hyperlink. In the example the \AAA No. 1, etc. are clickable links. \documentclass{article} \pagestyle{empty}% for cropping \usepackage{pgffor,hyperref} \newcount\countAAA \countAAA=0 \newcommand*\AAA{% \advance\countAAA by 1% ...

5

Something like this, however I did not check how \keys processes its input, I notice that it is not defined as a one parameter macro initially, it could do things with catcodes which here will not be possible. Perhaps though this does not happen, hence the proposed solution could be viable. (standalone class used to produce cropped image) ...

25

It's quite difficult to say what you can do with a \newcommand, because the possibilities are (really) infinite. I can talk about your two examples, pointing out the errors you're making. In the first definition you use \quote and \endquote and this is a mistake; \quote is the command LaTeX performs when it finds \begin{quote}, but this happens after a ...

3

You may appreciate a LaTeX3 version; \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\Assign}{m} { \andrew_assign:n { #1 } } \NewDocumentCommand{\Assigned}{m} { \andrew_assigned:n { #2 } } % syntactic sugar for shortening code \cs_new:Npn \__andrew_seq:n #1 { g_andrew_assignee_#1_seq } \cs_new_protected:Npn ...

5

\documentclass{article} \makeatletter \def\Assign#1{% if \DP@#1 is defined append to it otherwise create it \ifcsname DP@#1\endcsname\def\DP@tmp{\csname DP@#1\endcsname,\@currentlabel} \else\def\DP@tmp{\@currentlabel} \fi \expandafter\xdef\csname DP@#1\endcsname{\DP@tmp} \typeout{ASSIGN: \csname DP@#1\endcsname} } \def\Assigned#1{% \csname ...

9

The environment enumerate adds a group, thus the changes to \DP@#1 are local and lost after the environment closes. Thus the example makes the definition global: \documentclass{article} \makeatletter \def\Assign#1{% if \DP@#1 is defined append to it otherwise create it \ifcsname DP@#1\endcsname \edef\DP@tmp{\csname DP@#1\endcsname,\@currentlabel}% ...

7

The syntax \def\Assigned#1{} is incorrect. The proper way is \expandafter\def\csname Assigned#1\endcsname{}. That allows your code to compile. Also, the \edef is localized and can't be accessed at a higher level. Changing it to \xdef remedies that. \documentclass{article} \makeatletter \def\Assign#1{% if \DP@#1 is defined append to it otherwise create ...

2

This is a Plain TeX (or any other format) general purpose macro \scanthechars which accepts on input a string of character tokens of catcode 12 (1) and puts them in the same order but with transformed catcodes in a token list register called \replacetoks. (1) this update adds two \string's to the \@@scanthechars macro, and as a result the input is not ...

6

I took this question as a learning opportunity for me, more than an actual attempt to satisfy a question for you, and so my answer is not yet a generalized approach (though I think it could get there with a little work). I would say this method falls in your category #2, "Using a macro with an argument template (like what we do to see if a token is in a ...

2

Since it's a different technique, I also present the following: local macro definitions. \documentclass{article} \def\NineteenArgs#1#2#3#4#5#6#7#8#9{% \def\ArgsTenAndFurther##1##2##3##4##5##6##7##8##9{% \def\ArgNineteen####1{% ####1##9##8##7##6##5##4##3##2##1#9#8#7#6#5#4#3#2#1% }% \ArgNineteen% }% ...

11

My solution assumes, that there is a \ character at the beginning of the length register name, it is not tested for tikz etc. \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{etoolbox}% \usepackage{ifmtarg}% \makeatletter \newcommand*{\otherprovidelength}[2]{% \begingroup \escapechar\m@ne \xdef\@gtempa{\string#1}% ...

1

Wow! It was actually easy! I just removed the clauses that should be performed if the expression is true or false in the definition of the command. It now works both in tests like \ifboolexpr and by using it directly like \ifkeyempty{<key>}{<true>}{<false>}. \documentclass{article} \usepackage{tikz} \usepackage{etoolbox} \pgfkeys{ ...

9

Here's a LuaTeX-based solution. It (i) defines a Lua function that changes all instances of "var" (note the spaces before and after "var") to "\src{var}" and (ii) registers this function with the process_input_buffer callback. This callback operates on the entire input stream before TeX processes it. Separately, I define a TeX macro called \src so that TeX ...

14

TeX is a macro expansion system (like, but more powerful than) C's pre-processor but macros are introduced by \ so use \newcommand\var{\src{var}} then zz zzz \var\ zzzz Or you could define (say) | to be an active character \catcode`\|\active \def|#1|{\src{#1}} then zz zzz |var| zzzz It is, in theory, in very restricted circumstances, possible to ...

1

As noted in the comments, this might be a bad idea, since it is inconsistent with LaTeX syntax. The reason braces are not used within itemize is that it is already in an environment. The text is not the argument of \item as much as \item indicates where the text should be divided. In your usage however, the text should really be seen as an argument of ...

4

The following MWE makes each \heading{label}{title} clear a double-page spread, which deals with your first problem. The page headers are set using \markboth{title}{title}, which I haven't changed from the original MWE, but now that \heading always starts a new page, the page headers aren't getting confused by having multiple \heading on the same double-page ...

1

A macro such as this should do the trick: \newcommand{\mymessage}[1]{% \mybox{\hspace{6pt}\raisebox{-4pt}% {\includegraphics[scale=.30,keepaspectratio=true]{img/save_32.png}}\hspace{10pt}% \myinsidebox{\color{white}% {I file \texttt{.java} relativi alla lezione possono essere scaricati}% \href{#1}{cliccando qua}.}}} It would be called ...

1

\documentclass{article} \usepackage{tikz} \newcommand\multiplexer[1][1]{% \begin{tikzpicture}[scale=#1] \draw (0,0) -- (1,-0.5) -- (1,-1.25) -- (1.3,-1.25) -- (1,-1.25)-- (1,-2) -- (0,-2.5) -- (0,-1.75) -- (-0.3,-1.75) -- (0,-1.75) -- (0,-0.75) -- (-0.3,-0.75) -- (0,-0.75) -- (0,0); \end{tikzpicture} } \begin{document} \multiplexer[0.2] This is ...

10

It is definitely worthwile to study the loops in egreg's answer, but you can also use existing tools: The code copies all the set-up from your review, and then it uses \xintApplyInline to do the loops (non-expandably, it goes through here; else one could use\xintApplyUnbraced which prepares expandably the totality of the material before re-injecting it in ...

12

You can build your \lstdefine in pieces, adding to a token register: \documentclass{article} \usepackage{xcolor} \usepackage{textcomp} \usepackage{listings} \makeatletter \newif\iffirstchar\firstchartrue \newif\ifstartedbyadigit \newif\ifprecededbyequalsign \newcommand\processletter {% \ifnum\lst@mode=\lst@Pmode% \iffirstchar% ...

2

The question is not explicitly about package writing, therefore I wonder, why until now noone mentioned keycommand, what was made to provide for document writers “an easy way to define commands or environments with optional keys” (cite from package manual), but this package could used inside of packages, as well. So, let me show this here. Note, that there ...

3

Here's what happens. A section title is a moving argument, which means it's stored in memory and written out in the .aux file when the next page shipout occurs. When the write operation is performed, TeX expands macros without executing commands; moreover it is not in math mode at the time (it is in no mode, actually). This means that the conditional is ...

9

The @ at the beginning of a command name is common way to implement a private namespace, that is, to define commands which are hidden from the user. The user can therefore not inadvertantly modify them. This is a safety belt. The identifiant of a command—the text after the \ character—must be a sequence of letters. TeX's idea of which character is a ...

0

With \xintFor. The optional parameter may be anything, it does not have to be TA. If an expandable way had been asked for, this could be done with some other utilities from xinttools. \documentclass{article} \usepackage{amsmath, hyperref} \usepackage{xinttools} \makeatletter % with optional parameter. \def\erefs {\@ifnextchar[\@erefsTA\@erefs } ...

4

You don't really need any additional package, you can just use the loops already in LaTeX: \documentclass{article} \makeatletter \def\erefs#1{% \count@\z@ \@for\tmp:=#1\do{\advance\count@\@ne}% \edef\xtmp{\ifcase\count@\or\or\ and\ \else, and\ \fi}% \@for\tmp:=#1\do{% \advance\count@\m@ne \edef\tmp{% \noexpand\ref{\expandafter\zap@space\tmp\@gobble{} ...

4

Here is an adaptation from pgffor: Special treatment for last item in \foreach-list to provide special case handling of the last element: Code: \documentclass{article} \usepackage{tikz,amsmath} \newcounter{TotalNumberOfListMembers}% \newcommand{\SetTotalNumberOfListMembers}[1]{% \setcounter{TotalNumberOfListMembers}{0}% \foreach \member in {#1} ...

5


11

Here's a way without cleveref, but it needs a recent version of expl3: \documentclass{article} \usepackage{xparse,amsmath} \ExplSyntaxOn \NewDocumentCommand{\erefs}{sm} { \IfBooleanTF{#1} { \jlperla_erefs:Nn \ref { #2 } } { \jlperla_erefs:Nn \eqref { #2 } } } \seq_new:N \l_jlperla_input_seq \seq_new:N \l_jlperla_output_seq \cs_new_protected:Npn ...

3

if you need only the value and not its representation use : \newcommand\generator[1]{% \stepcounter{count}% \expandafter\edef\csname#1\endcsname{\arabic{count}}}

6

It's an expansion problem; \thecount needs to be expanded first: \documentclass{article} \newcounter{count} \newcommand\generator[1]% {% \stepcounter{count}% \expandafter\edef\csname#1\endcsname{\thecount}% } \generator{one} \generator{two} \begin{document} \one \two \end{document} This was similar to a problem I had and motivated A problem ...

3

We can't use numbers in LaTeX macros- see Defining commands/abbreviations that contain numbers and the links within for details. We can achieve close to your desired approach using a pgfplots-based approach by using styles: \pgfplotsset{ mystyle/.style={ solid, red, every mark/.append style={solid, fill=red}, mark=o}, ...

8

Remove the spurious braces in your definition: \documentclass{article} \newcommand{\mat}[2]{ \left( \begin{array}{#1} #2 \end{array} \right) } \begin{document} $\mat{c}{2\\3}$ \end{document} Why is this necessary? Brace groups are kind of a special thing in TeX (take a look at TeX by Topic for detailed information; run texdoc texbytopic ...

1

The tabstackengine package does this already, as I mentioned in my comment. The first form gives the parens with the stack, but all columns must be of the same alignment. The second form needs the parens added separately, but allows each column to have its own alignment. The examples below are not pretty, but are merely meant to demonstrate these ...

2

A \Longstack could be the thing. The [l] causes left alignment in the stack ([c] and [r] are options, too, for center- and right-alignment). I also need to reset the longstack gapsize in the preamble, because \baselineskip is set to 0pt in a tabular. The default \Longstack uses spaces as the end-of-line separators, unless reset with \setstackEOL{\\} or ...

0

I am not sure if you are really looking for a p{} column, but at least for your example table this basic solution is enough: \documentclass{article} \begin{document} \begin{tabular}{lp{1.5cm}} & long column name \\ interesting & 2 \end{tabular} \end{document} Note that inside a wider column (p{5cm}, for example) you can force ...

4

Here are two options: Replace the space character with \\ using xstring: \documentclass{article} \usepackage{xstring}% http://ctan.org/pkg/xstring % Ideas from Output generated macro content with newline (http://tex.stackexchange.com/q/124810/5764) \newcommand{\cellspacebreak}[1]{% \saveexpandmode\expandarg\exploregroups \StrSubstitute{#1}{ ...

8

The big problem is that you want to pass to \write commands such as \textbf or \textcolor that don't survive it. The kernel has \protected@write for this, but no “immediate” version. However, it's easy to define one as done in How to write the € symbol into a file, when using Package [utf8]{inputenc} You also must ensure that \textcolor is protected, ...

0

If you just want to redefine one or two commands for a specific document or so, doing it in the preamble is probably most straightforward. If the commands contain @, you need to treat that specially: \documentclass[10pt,notitle,nologo,totpages]{europecv} % How to acheive the line below? % \def\ecv@namekey{\ecv@utf{Name}} \makeatletter% because the line ...

4

Since you are redefining a macro that contains a @, you need to add \makeatletter and \makeatother. More info on this is detailed in the references listed below. \makeatletter \def\ecv@namekey{\ecv@utf{Name}} \makeatother Notes: What do \makeatletter and \makeatother do? \makeatletter explained Code: ...

3

Or you could always do something like this: \documentclass{article} \usepackage{graphicx,xparse} \NewDocumentCommand\quickfigure{O{width=0.6\linewidth} m o m}{% \begin{figure}[H] \centering \includegraphics[#1]{#2} \caption{#4}\IfNoValueTF{#3}{\relax}{\label{#3}}% \end{figure}} \begin{document} ...

5

Font encoding is built into the LaTeX format, the fontenc package mainly just gives an interface to setting the document defaults so you can use \chapter*{\centering{\LARGE\fontencoding{T1}\textsc{#1}}}

2

\newcommand\current[1][]{% \ifx\relax#1\relax\else \begin{frame}[label=#1] \frametitle{Outline} \tableofcontents[currentsection , hideothersubsections ] \end{frame}% \fi} Will use the frame only for \current[something] but not for \current or \current[]

3

String comparison under pdfTeX is made easily possible via the primitive \pdfstrcmp: \documentclass{article} % \pdfstrcmp{<string1>}{<string2>} % \pdfstrcmp compares two strings and expands to 0 if the strings are equal, to -1 if the first string % ranks before the second, and to 1 otherwise \newcommand{\myappend}[1]{% ...

4

I am not sure I understood the question. Here are two options: the first one, using an auxiliary command to add "BB" to #1 and the second one does the same but using \StrSubstitute from the xstring package: \documentclass{article} \usepackage{ifthen} \usepackage{xstring} \def\dothis{this} \def\dothat{that} \newcommand\myappend[1]{% \def\x{#1BB}% ...

4


3

With xargs you're limited to pass a default value to optional arguments, so it's not easy to distinguish when the argument is missing. Conversely, xparse provides \IFNoValueTF just for this case. For instance, one can say \NewDocumentCommand{\foo}{o}{% \IfNoValueTF{#1} {foo without optional argument} {foo with optional argument #1}% } With ...

3

In this answer, the macro \getargsC extracts each word of the argument into the macros \argi, \argii, etc. Then I set up a loop to grab the first letter of each word with a simple \def \documentclass{article} \usepackage{readarray} \usepackage{ifthen} \newcounter{index}\setcounter{index}{0} \def\firstletters#1{% \getargsC{#1}% ...

4

Almost a copy of cgnieder's solution in the link I posted. \documentclass{scrartcl} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand\shortenthis{ m } { \shorten_this:n { #1 } } \seq_new:N \l_shorten_seq \cs_new_protected:Npn \shorten_this:n #1 { \seq_set_split:Nnn \l_shorten_seq { ~ } { #1 } \seq_map_inline:Nn ...

Top 50 recent answers are included