# Tag Info

3

This solution allows word wrap and handles spaces between words. In addition, the [w] option allows the task to be performed on each word, rather than each character.' In the MWE, I demonstrate with variously defined tasks: overstrike each character (2 different settings) place a dot under each character place a semicolon under each word apply extra ...

8

You can use \@tfor. I provide also a better redefinition of the dot under according to your wish: \documentclass{article} \usepackage{graphicx} \let\d\relax \DeclareRobustCommand{\d}[1]{% \oalign{#1\cr\hidewidth\scalebox{0.5}{\textbullet}\hidewidth\cr}% } \makeatletter \newcommand{\ds}[1]{% \@tfor\next:=#1\do{\d{\next}}% } \makeatother ...

3

Always post fully compilable examples: This compiles just as expected \documentclass[a4paper]{article} \newcommand*\mycmd[3]{#1 & #2 & #3 \\} \begin{document} \begin{tabular}{ccc} \mycmd{a}{b}{c} \mycmd{d}{e}{f} \end{tabular} \end{document}

3

I guess you want to use \pdf@strcmp: \documentclass{article} \usepackage{pdftexcmds} \def\myoldvalue{emptystart} % initialize \makeatletter \newcommand\foo[1]{% \texttt{\string\myoldvalue}: \myoldvalue\\ ARG1: #1\\ \ifnum\pdf@strcmp{\myoldvalue}{#1}=\z@ TRUE% \else FALSE% \fi \par \gdef\myoldvalue{#1}% } \makeatother \begin{document} ...

2

This doesn't extend the existing \vphantom definition, but provides an alternative. It works in text mode as well as all styles of math mode. EDITED to remove package dependence on scalerel, but the \thisstyle and \savedstyle definitions that remain largely mimic those from the package (\ThisStyle and \SavedStyle). EDITED to add \wdphantom, \htwdphantom, ...

2

I use a similar command using xparse for setting languages: \DeclareRobustCommand{\setlanguage}[1]{% \IfEq{#1}{da}{% \renewcommand{\contentsname}{Indhold} % TOC Name }% {}% if not, then do this }% In the document, you would use: \setlanguage{da} % or some other ISO 639-1 code Also see ...

2

Thanks to the comments to my original question I was able to figure out a solution to my problem. However, I'm not sure if it is really appropriate. It works, but maybe there is a better solution? \NewDocumentCommand\mycommand{o o m m}{ \ifthenelse{\equal{#1}{hello}} {hello} {not hello} \ifthenelse{\equal{#2}{world}} {world} ...

14


19

For example, the switch \ifv@ can be split into two switches for the height and depth: \ifv@ht@ and \ifv@dp@. The the macros are changed in this way (unchanged macros are commented): plain TeX % \newif\ifh@ \newif\ifv@ht@ \newif\ifv@dp@ \def\vphantom {\v@ht@true \v@dp@true \h@false\ph@nt} \def\hphantom {\v@ht@false\v@dp@false\h@true \ph@nt} ...

7

\pdfmdfivesum also works on arbitrary strings: \pdfmdfivesum{Hello World} Result: B10A8DB164E0754105B7A99BE72E3FE5 The hex string can be decoded to save space: \pdfunescapehex{\pdfmdfivesum{Hello World}} \pdfmdfivesum is expandable and can be used inside \edef. \pdfmdfivesum works on file only, when the keyword file is given: \pdfmdfivesum file ...

6

\uppercase is not expandable. Therefore it does not expand inside \csname, which then chokes on \uppercase in the name. Also \expandafter\def\uppercase cannot expand \uppercase, thus \expandafter has no effect and the remaining \def\uppercase would change the definition of \uppercase. There \uppercase should be given outside: \def\makecs#1#2{% ...

5

There is no need to write #1 at all, because the argument of the new defined macro gets at the end of the definition text as last argument of \hyperlink. Then the new command can be defined without arguments and the argument in the input is later taken by \hyperlink directly. There are lots of (unwanted) spaces by line ends. I have added ...

6

You want \string# in the \write but to refer to # in the body of a definition you need ## so \string##

2

With forest, you can easily specify complex sub-trees, format them in different ways and mix explicit and automatic node creation within your tree. And you can do all this very concisely and without needing to worry about expansion issues. (At least, usually not.) For example: \documentclass[tikz,border=5pt,multi]{standalone} \usepackage{forest} ...

1

\protected@edef (see Steven’s answer), however, won’t inihibit the expansion of commands not declared as robust, unless you explicitly \protect them inside the replacement text. The following, trivial alternative \documentclass{article} \newcommand*{\mycmd}{% \edef\tmpcmd{\noexpand\textit{test}}% \tmpcmd } \begin{document} \mycmd \end{document} is ...

6


0

I found that it is much simpler not to use \noalign inside of the macros, but outside, where I know, that I'm inside a \halign. So \begindescrows ... can simply be nested at any level, using \noalign{\begindescrows ... .... \enddescrows} Actually it is good that the nesting and the halign characteristic is visible from outside of the macros.

4

\documentclass{memoir} \newwrite\testaux \immediate\openout\testaux=\jobname.myaux \begin{document} \makeatletter \immediate\write\testaux{\string\dont@want@spaces@after@this words} \immediate\write\testaux{\string\dont@want@spaces@after@this@either words} \makeatother Here is a body. \end{document}

7

The subcaption package delays the definition of subfigure and subtable when executing the \AtBeginDocument hook. So the error is because \newenvironment{subfigure} wants to define an already existing environment. Indeed, you get exactly the same error if you use \NewDocumentEnvironment. If you do \AtBeginDocument{% ...

2

Like this? You added \input at the wrong place, inside \linemark is where it should be. \documentclass{memoir} \usepackage[spacing, tracking]{microtype} \usepackage{libertine} \usepackage{xcolor} \usepackage{xspace} \nonfrenchspacing \microtypecontext{spacing=nonfrench} \newcounter{srcline} \newcommand{\linemark}{\stepcounter{srcline}% ...

9

A control sequence can't have two meanings at the same time. When you do \newcount\i you simply lose the dotless i. Fix (with some % at end of lines): % This accent macro works. Spelled out: r\'{\i}os % It also works inside another macro. \def\rios{r\'{\i}os} Macro: \rios % When I make a quasi-array by hand it works. \expandafter\def\csname ...

0

Update: I moved to TexMaker editor and found what I was looking for. Thanks to everyone who got interested in this question. If you have the same issue and are looking for an answer, here it is (for TexMaker users).

0

Christian, your solution fitted perfectly with the problem I had: I used it with sober colors and it gave a nice appearance to my document. Thanks for all!

0

I suppose that you load package paralist or enumitem which redefine the itemize environment. powerdotitself also loads by default the package enumerate. The solution is not to load paralist

1

This probably the requested result, at least it compiles without errors: \documentclass{article} \usepackage{hyperref} \newcommand{\legend}[3]{ \begin{itemize} \item Serial Number: #1 \item #2 \item #3%\href{http://#3}{#3}} \end{itemize} } \begin{document} \legend{5}{April 2015}{*.*.com} \end{document}

6

A slight modification of Manuel's answer to track lines even across paragraph breaks. \documentclass{memoir} \usepackage{xcolor} \newcounter{srcline} \newcommand{\linemark}{\stepcounter{srcline}% \textcolor{red}{\textsc{Line~\thesrcline}}} % Playing with the gobbling of \par \makeatletter ...

15

Now that you added a new answer with all your requirements, I created an expl3 solution. This comes with an extra feature, that counts all lines (so if you leave two blank lines, then Line 6 Line 7 Line 8 are added). \documentclass{scrartcl} \usepackage{xparse,xcolor} \newcounter{srcline} \ExplSyntaxOn \NewDocumentEnvironment{scrlines} { } { \endgraf ...

9

I'm not sure how robust this solution is, but I simply redefine the catcode for the newline character to make it active, then append the new command to it. \documentclass{memoir} \usepackage{libertine} % want this font \usepackage{xcolor} % for color \usepackage{xspace} \newcounter{srcline} \newcommand{\linemark}{% \stepcounter{srcline}% ...

2

It’s a bit sad to see how easily people are inclined to forget the good ol’ ways of doing things… Seriously, this question (like others I have already seen on TeX.SX) looks like a classical problem which is discussed, and solved, on page 111 of The TeXbook, where the \filbreak command is introduced. Quoting from there: The most interesting macro that ...

1

Probably you want \raggedbottom which means that when there's no space for something in a page a new one is open without flushing the contents to align to the bottom. Plus a {minipage} environment (which doesn't break across pages). Just put \raggedbottom in the preamble and use \newcommand\newpageoptional[1] ...

1

\documentclass[paper=A6]{scrartcl} \usepackage{needspace} \usepackage{blindtext} \newsavebox\TBox \newcommand\newpageoptional[1]{% \savebox\TBox{\parbox{\linewidth}{#1}}% to get the height of the text \needspace{\dimexpr\ht\TBox+\dp\TBox}% totalheight #1} \begin{document} \blindtext \newpageoptional{% Text and code 2 with blindtext ...

4

A suggestion, to keep track of options and arguments, is to replace the iteration environment by a command, having some optional arguments etc. The typesetting will be done within of a tcolorbox box environment. The counter is incremented automatically and reset with each section. Please note, that the label must be used in the first optional argument as ...

4


0

With the package longtable you can easily set the heading and ending of each page, using this code: %First page heading \hline \bfseries Head 1 & \bfseries Head 2 & \bfseries Head 3\\[5ex] \hline \endfirsthead %Following page headings \multicolumn{3}{c}{\emph{Continued from previous page}} \\ \hline \bfseries Head 1 & \bfseries Head 2 & ...

3

Basically this is a typo - the macro you call at the end, \cmelonalonateP, is not the one, \cmevalonateP, defined in the node. Additionally the unknown shape comes from a missing \ before the corresponding defining node command. However, ifthenelse would be much better replaced by using macros from the package etoolbox. This would allow you to shorten the ...

5

As you have rightly observed you are having problems because \c is already provided. Its purpose is to provide the cedilla diacritic, which can actually be added to a number of letters. The letter it is to be added to should appear as an argument of \c, e.g. \c{c} produces ç. Accordingly, if you want to define an alternative \c macro, you must issue ...

8

This redefines it for math mode only, retaining its original use in text mode. EDITED , per egreg's recommendation, to use \DeclareRobustCommand in lieu of \def. The \expandafter in the definition allows the following \fi to be absorbed, so that the text version of \c can operate on the actual argument that follows. \documentclass{book} \let\svc\c ...

7

I don't think this is possible without a .cwl file. But it's really easy to do this using a .cwl. You can just create a text file with the following code and name it mystyle.cwl. \qfigure{caption}{label}{mincapwidth}{width}{filename}#g The #g just indicates to TeXstudio that this is a command that includes a graphics file (so that the image will pop up ...

1


1

Using pgfkeys I wrote some macros to do something more general than this. As that question has been closed I will reproduce it here. Using my code you can type your different language sections using the environment SelectEnvironment, tagging it as either Chinese or English: \begin{SelectEnvironment}[English] English paragraph 1 goes here. ...

4


1

I had a very similar problem with authsepword and authignoreword. Moving them just before \begin{document} fixed the problem.

1

As an extension of the @YiannisLazarides answer, you can use mfirstuc which is included with TexLive 2014. This will take care of the capitalisation for you, and you won't have to repeat yourself when defining the upper-case version of your command. \documentclass{article} \usepackage{mfirstuc} \def\secname{fancy section} ...

5

If you have a simple macro, say with two undelimited arguments, it's possible to patch it for becoming \long without e-TeX: \def\foo#1#2{#1-#2} \begingroup\toks0=\expandafter{\foo{#1}{#2}} \edef\x{\endgroup\long\def\noexpand\foo##1##2{\the\toks0 }}\x \foo{a\par b}{c\par d} {\tt\meaning\foo} (see http://tex.stackexchange.com/a/39980/4427 for an ...

11

To answer the questions backwards, the difference is that \spx{} expands to nothing whereas ^{} produces an empty superscript atom. Such an empty superscript field is not equivalent to not having a superscript, and can affect the position of a subscript on the same base. \expandafter\@gobble \else \expandafter\@firstofone \fi {^{#1}}% removes the ...

1

The simplest way is adding the conditional at the point of use: \def\DisplayNumber#1{% Result is: \ifx&#1&0\else#1\fi } Instead of the \ifx&#1& test for emptyness, you can use \if\relax\detokenize{#1}\relax provided you have e-TeX extensions enabled. You can also define a utility macro: ...

12

You can not turn off the error check however plain (and latex) have \endgraf which is \let (rather than \def) to the primitive \par and is there for exactly this reason so you can use \short{a\endgraf b} the only other alternative would be to define a \long version of the command, which is trivial if copying the source is a possibility, but can be tricky ...

4

e-TeX's \detokenize helps to convert an arbitrary argument to something, which is safe to be used inside \csname: \expandafter\def\csname\detokenize{some text \foo{hello} \bar some more text}\endcsname{}

5

If you don't plan to have unbalanced braces inside \csname...\endcsname when you use it in the argument to anothe command, you can directly use { and }. For the backslash, just use \string; the only problem is to persuade TeX not to gobble a space after the mock control sequence: \expandafter\def\csname some text\string\some\space more} text\endcsname{} ...

5

\makeatletter \expandafter\def\csname xx\expandafter\@gobble\string\{yy\endcsname{} \expandafter\show\csname xx\expandafter\@gobble\string\{yy\endcsname

Top 50 recent answers are included