# Tag Info

3


4


0

Ok, this has already been answered so I just want to contribute with the usage of the \phantom command. \begin{document} This text will be visible. \\ \phantom{This text will be invisible} \\ \fbox{\phantom{This text will be invisible too, but a box will be printed arround it.}} \end{document}

1

If the installation of the add-ons "LaTeXify" and "JabRef" have been successful, then WinEdt toolbar must contain the items related to these packages. The only reason I see for not having them visible is that you are not using the default toolbar in WinEdt. You must have chosen one of the alternative toolbars available in Options -> Toolbar menu. In fact, ...

3

A space following a command name is just taken to end the name and not add a space so \sg s does what you need.

0

Or even shorter: \documentclass{article} \newcommand{\eq}[2]{$$\label{eq:#1} #2$$} \begin{document} \eq{1}{x + y = z} \eq{2}{a + b = c} \end{document} After you type in your doc, you can "translate" back your source tex file to regular environments with sed or alike. I do this very often despite what others have ...

2


6

Thanks for comment by Mico, this is the suggested pattern to use. ps. I am not a regular expression expert and do not play one on TV, but the nice thing about lualatex is one can use them now if needed with Latex. \documentclass{article} \usepackage{luacode} \newcommand{\FirstWord}[1]{\luaexec{tex.print(string.match('#1', '\%w[\%w\%-]+'))}} \begin{...

2

I fixed the issues in your code; apart from typos, it's wrong to load xunicode and fontspec should be loaded instead. The problem is in untimely expansion of \undbefehl, which should be robust. I used \newrobustcmd that's provided by etoolbox, which is loaded by polyglossia. Also, the change in the .bst file should be FUNCTION {bbl.and} { "\undbefehl{}" } ...

11


0

You can try to experiment with this: \newwrite\tmpfile \newcount\numpar \newcount\numpars \openin10=\jobname.num \ifeof10 \numpars=-1 \else \closein10 \numpars=\input\jobname.num \relax \fi \immediate\openout\tmpfile=\jobname.num \def\thelasttext{{\bf (The last blaf.)}} \def\par{\ifhmode \global\advance\numpar by1 \ifnum\numpar=\numpars \...

1

With etoolbox: \usepackage{etoolbox} \newcommand{\appendtolist}[2]{% \ifundef{#1}{\gdef#1{== \string#1 ==}}{}% \gappto#1{^^J#2}% } \appendtolist\mylistmacro{abc} \appendtolist\mylistmacro{def} \appendtolist\mylistmacro{ghi} \appendtolist\mylistmacro{lmn} \typeout{\mylistmacro} Output on terminal: == \mylistmacro == abc def ghi lmn More ...

5


7

It is not that they are single letter particularly it is that they are used internally already in latex (and plain tex) most accent commands are single character \c, \r \v etc If you redefine these commands then you break accented letters even if they are input as characters via inputenc. \documentclass{article} \usepackage[utf8]{inputenc} \begin{document}...

3


5

Does it really have that? I couldn't find any instances via google except for this question. some journal classes, eg jss.cls have \newcommand{\ISBN}[1]{\def\@ISBN{#1}} which is much more reasonable, and I expect (hope!) the code you found was intended to be of that form, and is an error in the class. As shown, it's legal as Werner explains but it is a ...

4


2

Your assignments within the macro make it not expandable, and therefore you cannot nest it within other macros. If you go without the assignment, then you can nest them: \documentclass{article} \newcommand{\nand}[2]{% \ifnum #1=#2 \ifnum #1=1 0\else 1 \fi \else 1 \fi } \begin{document} \verb|\nand{0}{0}|: \nand{0}{0}% 1 \verb|\nand{0}{1}|: \nand{0}{...

4

It works if you write it this way: \newcommand\nand[2]{ \ifnum #1=#2 \ifnum #1=1 0 \else 1 \fi \else 1 \fi }

5

There are two issues, really. The first is that it is an extremely bad idea to redefine basic TeX and LaTeX macros unless you absolutely know what you are doing. The second is that \; is not valid outside maths mode. Perhaps you want something like \documentclass{article} \begin{document} \newcommand{\drm}{\ensuremath{\;\mathrm{d}}} \drm \end{document} ...

0


7


0


3

Don't use a command with an argument -- this will always be difficult if catcode changes are involved. Better use the comment package: \documentclass{article} \usepackage{comment} \includecomment{instructor} %\excludecomment{instructor} \begin{document} bllb \begin{instructor} some text \catcode\%=11 12 %% 13 \catcode\%=5 \begin{verbatim} \section \end{...

1

This isn't a great solution, but it works. A better but more complicated solution is in the edit below. Wrap each use of the \instructor{} macro that contains literal % characters in \catcode changes, e.g. in the original knitr code: \catcode\%=11 \instructor{ <<>>= 1 %% 2 @ } \catcode\%=5 A TeX wizard might know how to build that into the ...

3


3


3

You can do it, but I see no point: if the superscripts and subscripts should be outside the scope of the overline, place them outside the argument. Note that the k feature of xparse I'm using is classified as experimental and may disappear in the future (not really likely). \documentclass{article} \usepackage{xparse} \newcommand{\mset}[1]{\makemset#1} \...

2

Here's a LuaLaTeX-based solution. It scans the input for instances of \mset{...} and rearranges the argument "on the fly", so that only leading single or multiple letters are part of the argument of \mset. Whitespace before or after the left-hand curly brace is allowed. \documentclass{article} \newcommand{\mset}[1]{\overline{#1}} \usepackage{luacode} \...

7

Here is an example how to strip the last s using TeX primitives. The expandable macro \striplastS is created. \striplastS{texts} expands to text and \striplastS{text} expands to text too. \def\striplastS#1{\striplastSa{#1}#1\end s\end\eend} \def\striplastSa#1#2s\end#3\eend{\ifx\end#3\end#1\else#2\fi} %test: \message{\striplastS{text} \striplastS{texts}} % ...

2

This is my answer there, including the new command. You just have to \protect it: \documentclass{article} \usepackage{stringstrings} \usepackage{makeidx}\makeindex \begin{document} \newcommand{\indexMonster}[1]{% \testmatchingchar{#1}{$}{s} \ifmatchingchar \substring[q]{#1}{1}{$-1}\index{\thestring} \else \index{#1} ...

4

You can use the stringstringspackage by Steven B. Segletes: \documentclass{article} \usepackage{stringstrings} \usepackage{makeidx}\makeindex \begin{document} \newcommand{\indexMonster}[1]{% \testmatchingchar{#1}{$}{s} \ifmatchingchar \substring[q]{#1}{1}{$-1}\index{\thestring} \else \index{#1} \fi} \...

3

Even with your definition, you can use \mset R_2^1 and it will work as you want. In any case, in case you definitely want \mset{R_2^1} you can use \newcommand*\mset[1]{\overline#1} Which will work as you want, and it will even work with the \mset R_2^1 syntax.

4

This solution uses xstring. Since there are some terrible monsters named albatross which are intesly feared, and you of course will be writing a lot about, I have also made a warning system for when the names of monsters have been changed. You can of course drop this if you feel like. If you want to override the test for monsters ending in s, simply add ...

9

Use \let\bulleto\bullet to preserve the old meaning before you use \renewcommand to redefine it. See also What is the difference between \let and \def?

3

The file url.sty defines \path as follows: \@ifundefined{path}{\DeclareUrlCommand\path{\urlstyle{tt}}}{} In constrast, your (re)definition of \path does not use the \DeclareUrlCommand machinery. That's why it gets hung up on the "\}" substring in \path{C:\Code\Pre-requisite-Setup\}. (Note also that \path -- as defined in the url package via \...

1

\csdef etc. does infact allow numbers in 'command' names, but here's another way using \@nameuse and \@namedef from LaTeX2e core with expansion of the counter values -- I don't think that etoolbox is needed here for such an approach! \documentclass{article} \newcounter{cntLocalProblem} \newcounter{cntProblem} \newcommand{\fileprefix}{foo} \makeatletter ...

8

The code \newcommand\test[1]{#1:~\ignorespaces} will do what you want. The space should be part of the replacement text, as you seem to want it; with \ignorespace, spaces following the argument will be gobbled.

6

Package xspace can be your friend: \documentclass{article} \usepackage{xspace} \newcommand*{\test}[1]{#1:\xspace} \begin{document} \test{A}This is some text \test{A} This is some text \end{document} However, xspace does not add a space before punctuation characters, for example, its usage is intended for stuff inside text. Manuels's solution or ...

0

\strip@pt removes the unit pt and eTeX's \dimexpr can be used for the calculation: \documentclass{article} \usepackage{siunitx} \makeatletter % #1: macro, which gets the result of the conversion without unit % #2: length expression \newcommand*{\converttomm}[2]{% \edef#1{% \strip@pt\dimexpr(#2)*2540/7227\relax % 72.27 pt = 1 in = 25.4 mm }% } \...

0

Length conversion to decimal using LaTeX3: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn %\cs_new_eq:NN \calc \fp_eval:n \cs_new_eq:NN \convertlen \dim_to_decimal_in_unit:nn \ExplSyntaxOff \begin{document} \verb|\textwidth| in \verb|pt|s: \the\textwidth \makeatletter \verb|1mm| in \verb|pt|s: \setlength{\@tempdima}{1mm}\the\@tempdima \...

1

You can use my calculator package. The \LENGTHDIVIDE command divides two lengths and stores result as a number in a new command, as you need. Try this code: \documentclass[a4paper]{article} \usepackage{calculator} \begin{document} \LENGTHDIVIDE{\textwidth}{1mm}{\size} \size \end{document} In a standard a4 article \size returns 121.25427

2

For fun, here is a LuaTeX based solution. I am using ConTeXt + MetaPost because I am more familiar with those, but the code could be translated to LaTeX + TikZ (or LaTeX + MetaPost). \startluacode local metafun = context.metafun thirddata = thirddata or {} thirddata.ShowBitArray = function(bitarray) local hsize = string.todimen(tex.get("...

3

A TeX-y solution (built on Heiko's) using \csname, since your data contains only two different values : \documentclass{article} \usepackage{tikz} \begin{document} \expandafter\def\csname box0\endcsname#1#2{} \expandafter\def\csname box1\endcsname#1#2{\fill[orange] (#1-1, -#2+1) rectangle ++(1, -1);} \begin{tikzpicture} \def\BITARRAY{ {1,0,0,1}, {...

4

You can't say \ifthenelse{\value{1}<1}{... because 1 is not a counter and \value{} takes the name of a counter as its argument. This is why you get strange errors complaining about not being about to use \else after \the. The value of the counter mycounter is typeset using \themycounter so \value{1} tries something like \the1 which doesn't make sense. ...

5

The macro \BITARRAY has already almost the form, how it can be easily used by TikZ's \foreach. The additional surrounding braces are not needed and there should not be a space after the last element. First the cells with values 1 are filled. During the loop, the values of \x and \y are stored in global variables to have the maximum values after the loops. \...

8

whatever is defining \r is incorrect and breaking latex so you should report a bug even if you can not change it. Use \let\temp\r before importing the bad definitions and put \let\r\temp after them to restore \r. You could of course redefine \AA but \r is an encoding specific command so it is (re)defined if you switch encodings such as \usepackage[T1]{...

4

If you only need to export a value as a macro, i.e. a macro without a signature, then you could also use the token library of LuaTeX. The same as in Joseph's answer applies here: Because luacode* is grouping you have to add the "global" specifier. \documentclass{article} \usepackage{luacode} \begin{luacode*} MyVal = 123 token.set_macro("MyVal",MyVal,"...

5

The column specification of tabular is mandatory not optional so {} not [] and your true/false switch would not work as written as each tavle cell is a group so the setting was lost at each & or \\ \documentclass[a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage{array} \title{Your Paper} \author{You} \begin{document} \newcommand*{\ruleset}[1]...

1

\def\activatelayerone#1{% \def\layertwo##1{% \appendmacro{##1} }% }% Apart from defining \layertwo to be append and add a spurious space because of the missing %, this acts as \@gobble to discard the next token as #1 is not used. Here the next token is \layertwo so that is discarded and {item5} is just typeset at that point.

Top 50 recent answers are included