New answers tagged

0

An alternative solution is to have a button that skips the extra material. This has the disadvantage that you have to remember to press the “don’t show the extra material” button when you get to that slide, but it has two advantages. Firstly, the extra slide is right there next to the main material rather than hidden off in an appendix, which might make it ...


1

I can offer an environment DifferentFileContents which has the same syntax as the filecontents*-environment. The content of the DifferentFileContents-environment will be compared to the content of the file specified. In case the contents differ or the file specified does not exist, the file will be destroyed and rewritten/will be created anew with the ...


3

The varioref package and its \vref user macro accomplish what your \fullref macro aims to do. The package works with babel, and it offers ways to customize what is supposed to be typeset if the cross-referenced object happens to be on, near, or far away from the cross-referencing call-out. This customization works by redefining the macros \reftextbefore, \...


4

Checking if a file has changed, as Ulrike says, requires to compare it against some previous state of the file. Here's an implementation using roughly the same method as in Rmano's answer of storing the MD5 sum of the file in the .aux file, and also storing one MD5 per file in a property list, so that you can have multiple files. \IfFileChangedTF checks if a ...


1

\documentclass{standalone} \usepackage{tikz} \usetikzlibrary{math} \begin{document} \begin{tikzpicture} \foreach \x in {1,...,4} { \tikzmath {\xEnd=\x+1;} \foreach \y in {1,...,\xEnd} { \fill[red!50] (\x,\y) ellipse [x radius=3pt, y radius=6pt, rotate={ifthenelse(\x==1 || \x==2 && \y==1,0,-45)}]; }} \draw [|-|] (.895,1) -- ++(0.211,0); \end{...


0

Found a much simpler solution. Below are the key ideas: \ifthenelse from ifthen package in CTAN is that powerful conditional command. \ifthenelse{<test>}{<then clause>}{<else clause>}is the command format wherein <test> is a boolean expression using the infix connectives, \and, \or, the unary \not and parentheses \( \). Also \OR ...


4

I suppose that the situation is the following. We have a LaTeX file, call it filechanged.tex, that is run with pdflatex filechanged. In the same directory, I have another file, myfile.txt. When I run pdflatex filechanged, I want to do different processing if myfile.txt has changed since the previous run or not. My solution: It is based on @Skillmon ...


8

In order to reproduce the picture, the test should be 1 ≤ x < y. You can parametrize the rotation angle and test for the two special cases. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \foreach \x in {1,...,4} { \foreach \y in {1,...,4} { \def\rotation{-45} \ifnum\y=1 \ifnum\x=1 \def\rotation{0} \fi ...


6

LaTeX's ifthen package has some facility for combining conditionals with \and and \or, \not and parentheses. But your case is easy to do with \ifnum: \ifnum \x<\y \ifnum \x>1 \breakforeach \fi\fi


3

amsthm's internal macro \@ifempty is what you need. Alternatively, you can use \ifstrempty{<string>}{<true code>}{<false code>} from etoolbox package. \documentclass{article} \usepackage{amsthm} \makeatletter \newtheoremstyle{mytheorem} {\topsep} {\topsep} {} {1em} {\bfseries} {.} { } {% \@ifempty{#3} {\thmname{#1}...


3

The “official” source for TeX primitive commands is the TeXbook, whose TeX source is available online (even on CTAN), but not for making the printed copy. The source starts with % This manual is copyright (C) 1984 by the American Mathematical Society. % All rights are reserved! % The file is distributed only for people to see its examples of TeX input, % not ...


1

If you want to link to a specific paragraph/section or the entire law with some text more often, you can define a dedicated command for that. I'm using etoolbox's \ifblank to test if the string is empty, because I generally prefer etoolbox tests over ifthen, but that is just a matter of style. \documentclass[12pt]{article} \usepackage{etoolbox} \usepackage{...


2

You need something expandable, ifthen and xifthen won't work. \documentclass[12pt]{article} \usepackage{hyperref} \begin{document} \ExplSyntaxOn \newcommand{\gesetze}[2] { http\c_colon_str//www.gesetze-im-internet.de/#1/ \tl_if_blank:nF {#2}{__#2.html} } \ExplSyntaxOff \href{\gesetze{bgb}{622}}{This is the 622nd paragraph in the law.} \href{...


1

Note that line 167 of beamerbasetitle.sty contains \author{}, hence \beamer@shortauthor is always defined and initially empty, and one can/should test if meaningful \author{...} is used by \ifx\beamer@shortauthor\@empty. The following example outputs "No author given Some more information" on first frame, and "Author | Some more information&...


6

The test fails to show equality on (at least) two levels. First level \MakeUppercase and \MakeLowercase are instructions to print the uppercased or lowercased versions of their arguments. They don't “directly” transform their arguments. Second level \ifx only compares the “surface meaning” of two tokens without any macro expansion. In particular, two macros (...


9

Like Donald Hosek said, \ifx doesn’t expand its arguments. You’re comparing the unexpanded macros \MakeUppercase{1} and \MakeLowercase{1}. You could fix this by fully expanding the macros you compare. However, that doesn’t give you a complete solution, because \MakeUppercase and \MakeLowercase are not expandable. So, \edef\upperone{{\MakeUppercase 1}} ...


11

You're going to get different results because you're comparing the definitions of the two macros. \MakeUppercase{1} is not the same as \MakeLowercase{1} It's worth noting that the \MakeUppercase and \MakeLowercase macros are themselves complicated enough that the naïve approaches to trying to expand them to get the results in plain text will still not give ...


2

No packages required. \documentclass{article} \newcommand\F[1]{\Faux#1\endFaux} \makeatletter \newcommand\Faux{\@ifnextchar(\Fnoadd\Fadd} \makeatother \def\Fadd#1\endFaux{F(#1)} \def\Fnoadd#1\endFaux{F#1} \begin{document} $\F{(x)}$ $\F{(G(x))}$ $\F{x}$ $\F{G(x)}$ \end{document}


1

You can achieve this using the following code: \usepackage{xstring} \usepackage{ifthen} \newcommand{\F}[1]{ \StrLeft{#1}{1}[\firstletter]% \StrRight{#1}{1}[\lastletter]% \ifthenelse{\equal{(}{\firstletter} \AND \equal{)}{\lastletter}}{F#1}{F(#1)}% } It basically checks what the first and last characters of the argument are, and if those are '(' ...


0

Your criteria seem to be to a) use LaTeX (i.e. limit/avoid TeX primitives) and b) input a markdown pre-processed header before certain LaTeX files. If so, this will do what you want. \documentclass{article} \usepackage{etoolbox} \newcommand*{\inject}[2][]{ \ifstrempty{#1} {\input{#2}} {% \input{.cache/#1} \input{#2}} ...


2

The problem is that \ifstrequal does no expansion to its arguments. This might be solved by forcing expansion, but let me present a different solution based on expl3 and its richer supply of functions and tests. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\inject}{m} { \utkarsh_inject:n { #1 } } \tl_new:N \...


5

The manual of the etoolbox package says: \ifstrequal{⟨string⟩}{⟨string⟩}{⟨true⟩}{⟨false⟩} Compares two strings and executes ⟨true⟩ if they are equal, and ⟨false⟩ otherwise. The strings are not expanded in the test and the comparison is category code agnostic. Control sequence tokens in any of the ⟨string⟩ arguments will be detokenized and treated as ...


1

This should be solved by using ##1 instead of #1, because you want to define a command inside the argument passed to another macro. See What is the meaning of double pound symbol (number sign, hash character) ##1 in an argument? for more information.


6

The reason for the error is that the array does not contain integers but ifnum requires an integer. You can use pgfmathparse to parse the entry from the array and pgfmathresult in the ifnum statement. Also you need to use i-1 otherwise the last array index is out of bounds, because arrays are indexed starting with 0. \def\array{{1,0,1,1,1,1}} \foreach \i in {...


Top 50 recent answers are included