Tag Info

New answers tagged

4

Try to remove the curly braces around \x in \pgfmathsetmacro\xsh{...}: \documentclass[a4paper]{article} \usepackage{tikz} \usepackage{ifthen}\newboolean{color} \begin{document} \begin{figure}[h] \begin{center} %%%%%%%% Set function values %%%%%%% % Set the x = a and x = b values of the % domain here where a <= x <= b. ...


11

Pgfmath offers also boolean compositions hence you can fall back to it and test the resulting boolean with \ifnum; \setbeamertemplate{background}{% \begin{tikzpicture} \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight); \pgfmathparse{\value{page}<33 &&\value{page}>1?int(1):int(0)} \ifnum\pgfmathresult>0\relax% Not the title ...


13

The primitive \ifnum accepts only a single test, it's not able to do 1 < \value{page} < 33 Thus you need to make in more steps: \setbeamertemplate{background}{% \begin{tikzpicture} \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight); \ifnum \value{page}=1 \fill[color=MedianBrown] (0,1.2) rectangle ...


4

You need to place the \random generation outside the comparison: \documentclass{article} \usepackage{xifthen} \usepackage[first=0, last=1, quiet]{lcg} \begin{document} rand sequence: \rand\arabic{rand}\rand\arabic{rand}% \rand\arabic{rand}\rand\arabic{rand}\rand\arabic{rand}% \rand\arabic{rand}\rand\arabic{rand}\rand\arabic{rand} ...


3

Though it's most likely too late for the OP, I just worked out my own switch and thought I'd share it here for future readers. My solution uses solely the package xifthen (ifthen suffices too, but I already had xifthen installed...). % Switch implementation \usepackage{xifthen} \newcommand{\ifequals}[3]{\ifthenelse{\equal{#1}{#2}}{#3}{}} ...


2

In order to perform a length test using ifthen you need to explicitly state it: \ifthenelse{\lengthtest{<dimen>?<dimen>}}{<true>}{<false>} where ? is one of <, = or >. I've adopted a more old-school way of testing dimensions using \ifdim: \newcommand{\choice}[4]{% \settowidth\widthcha{AM.#1}\setlength{\widthch}{\widthcha}% ...


7

\ifthenelse is "normal" LaTeX code. Therefore you can not use this command inside a TikZ path specification. But since the node text is put in a normal TeX box you can use \ifthenelse inside the node text. So you can try \documentclass[tikz,margin=5mm]{standalone} \usetikzlibrary{graphs,graphs.standard,quotes} \usepackage{ifthen} \begin{document} ...


5

You can pre-compute an array of points using \ifthenelse, then use them in the \foreach. I have no idea what you are trying to accomplish with the second example. \documentclass{article} \usepackage{mathptmx} \usepackage{tikz} \usepackage{verbatim} \usetikzlibrary{arrows,shapes,graphs,graphs.standard,quotes} \usepackage{calc}% http://ctan.org/pkg/calc ...


7

Here is a solution for this problem, using (perhaps abusing) only expl3 features. I'm not really sure about the usefulness of this code. ;-) \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\NewOnceMacro}{m m m} { \grill_new_once_macro:Nnn #1 { #2 } { #3 } } % an addition to the kernel functions \cs_set_eq:NN \use_none: ...


6

You could do this but it's so wrong, why mix expl3 and etoolbox tests and why all the toggle stuff, if you want \foo to just execute once define it to be \def\foo{hello\let\foo\@empty} No need for a separate toggle macro. but anyway: %% Uncomment the following \def to get the failing test case. \def\UseXparseForDefiningMacro{}% Works if commented out ...


5

The syntax is \ifx\a\b stuff \else other stuff \fi and no grouping is implied. By going \ifx\a\b{ stuff }\else{ other stuff }\fi You were keping both branches in local groups. Note also that you are missing lots of % from ends of lines if you do not want to introduce white space into the output.


5

\def\foo#1{% \ifcase\numexpr`#1 - `a\relax case a \or case b \or case c \fi} then \foo{b} probably expands to case b


4

I use something like this: \ProvidesClass{superclass} \RequirePackage{xkeyval}% better option processing - there are many other possibilities as you probably know so just adapt as needed \def\myclasstype{article}% make sure a default is defined \DeclareOptionX{article}{% \gdef\myclasstype{article}} \DeclareOptionX{report}{% ...


3

An alternative way that doesn't require shell escape. Let's say your file is called file1.tex. Then you can organize it as follows: \documentclass{book} \providecommand{\INCLUDE}[1]{} \begin{document} First paragraph of first file. \INCLUDE{file2} Last paragraph of first file. \end{document} If you call the LaTeX run by pdflatex ...


7

Here is a \providelength command that will define a new length if not already defined, but also checks whether the command passed as argument has been defined with \newlength, in order to issue an error message if you try to use, say, \providelength{\textit}. \documentclass{article} \makeatletter \newcommand{\providelength}[1]{% ...


5

Your answer appears to work. A simpler method might consist of first \let-ting the length variable in question to \relax and then applying \newlength to it. Put differently, if you can't remember if a certain macro name has been used before to denote a length parameter (or anything else, really!) and if you're comfortable with (re)using it anyway, you can ...


2

Ok, so first I looked up the definitions of \newlength and further using texdef: $ texdef -t latex \newlength \newlength: macro:#1->\@ifdefinable #1{\newskip #1} $ texdef -t latex \@ifdefinable \@ifdefinable: \long macro:#1#2->\edef \reserved@a {\expandafter \@gobble \string #1}\@ifundefined \reserved@a {\edef \reserved@b {\expandafter \@carcube ...


4

You are using the book class with chapters. Then it is easy with \includeonly \documentclass{book} \includeonly{file2,file3}% controlls what will be included \begin{document} First paragraph of first file. \include{file2} \include{file3} Last paragraph of first file. \end{document} You can also use an external file include.cfg which has only the ...


7

Edit Improved version There are two basically two problems: \ifstrequal does not expand its arguments The content of the environment variable has a trailing whitespace character at the end, which means yes will become yes' ', so that the test fails. I could not figure out the reason up to now. By usage of the xstring package command \StrGobbleRight ...



Top 50 recent answers are included