Tag Info

Hot answers tagged

7

I'm not sure to understand correctly. Loading xstring you can define something like \DeclareRobustCommand{\disclaimer}[1]{% \IfEq{#1}{en}{English disclaimer}{}% \IfEq{#1}{de}{German disclaimer}{}% \IfEq{#1}{da}{Danish disclaimer}{}% } and use it as in the following MWE \documentclass{article} \usepackage{fontspec} \usepackage{xstring} ...


7

Yes, it's possible, by coupling this with \DeclarePairedDelimiter. \documentclass{article} \usepackage{mathtools,amssymb} \makeatletter \DeclareRobustCommand{\E}{\operatorname{\mathbb{E}}\@ifnextchar_{\m@Es}{\m@Epd}} \newcommand{\m@Es}[2]{_{#2}\m@Epd} \DeclarePairedDelimiter{\m@Epd}{(}{)} \makeatother \begin{document} $\E{f(x)}$ $\E[\big]{f(x)}$ ...


7

Without using any extra macros or packages, here is a solution which runs in linear time O(k), i.e. linear in k, where k is the number of colors (equal to 6 in your post). It is all about conditions. The two conditions that I use here are: \ifnum \k > \p{ \ifnum \k < \numexpr\num+\p+1 \relax ... These conditions precisely pick only the values ...


7

It's nothing more than a standard macro. Instead of \z you could have used \xxxyyy or any other valid macro name. The line \pgfmathrandomitem\z{mylist} simply selects an item from the mylist list and stores it in the macro \z. Then \z\prunelist{mylist} shows the item stored in \z and removes it from the list.


6

Use a stack. The current (default) gap is 3pt, but you can alter that with \stackunder[8pt]{...} or some other suitable dimension. I left the top line horizontally positioned where the OP had it (which is not centered). If one wants it centered, the follow-up coding below will achieve that. \documentclass{article} \RequirePackage{graphics,stackengine} ...


6

The LaTeX kernel has features for working on comma separated lists: \documentclass{amsart} \usepackage{tikz} \newcount\p \def\sillyexample#1#2{% \p=0 \addquotes\sillyexampleargtwo{#2}% \foreach\i in {#1}% {% \foreach\j in {1,...,\i}% {% \pgfmathparse{{\sillyexampleargtwo}[\j+\the\p-1]}% \node [\pgfmathresult] at (\j+\the\p,0) {\i};% }% ...


6

New Answer As the edited question is unrelated to the original... \loop is a simple macro based on one in plain TeX and can not be nested. Presumably it is used in the pgf code somewhere. Adding a grouping level solves it: \documentclass{amsart} \usepackage{tikz} \makeatletter \def\prunelist#1{% \expandafter\edef\csname pgfmath@randomlist@#1\endcsname ...


5

Here I just create a recursive helper routine \addquotes. \documentclass{amsart} \usepackage{tikz} \def\sillyexample#1#2{ \newcount\p \foreach\i in {#1} { \foreach\j in {1,...,\i} { \pgfmathparse{{\addquotes#2,\relax}[\j+\the\p-1]} \node [\pgfmathresult] at (\j+\the\p,0) {\i}; } \global\advance\p by \i } } ...


5

You need to tell LaTeX hoy many arguments the command has with [n], in this case just one [1]. \newcommand*\alphabetExample[1] {{\fontfamily{#1}\selectfont Aa\-Bb\-Cc\-Dd\-Ee\-Ff\-Gg\-Hh\-Ii\-Jj\-Kk\-Ll% \-Mm\-Nn\-Oo\-Pp\-Qq\-Rr\-Ss\-Tt\-Uu\-Vv\-Ww\-Xx\-Yy\-Zz\-0123456789}}


5

A simple solution that doesn't check for the length of the string: \documentclass{article} \makeatletter \newcommand{\printpgp}[1]{\print@pgp#1\@nil} \def\print@pgp#1#2#3#4#5\@nil{% #1#2#3#4% \ifx\\#5\\% \expandafter\@gobble \else \expandafter\@firstofone \fi {~\print@pgp#5\@nil}% } \makeatother \begin{document} ...


5

\documentclass{article} \usepackage{graphicx} \newcommand{\modtitle}[2]{% \begin{center} \vspace*{-5\baselineskip} \makebox[0pt][c]{% \begin{tabular}{@{}r@{}} \resizebox{\dimexpr1.25in+\linewidth}{!}{\textsc{#1}}\\ \large \textsc{#2} \end{tabular} } \vspace{\baselineskip} \end{center} } \begin{document} ...


4

You could create an emulation of what \newcommand with two optional argument does, but I think it's better using xparse and expl3 for this: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\createCMDSH}{mmmm} { \guuk_create_cmdsh:cxx { #3#2 } { #1 } { #4 } } \cs_new_protected:Nn \guuk_create_cmdsh:Nnn { ...


4

\documentclass{scrartcl} \newcount\pgpcount \long\def\firstofone#1{#1} \long\def\gobbleone#1{} \def\dopgp#1#2#3#4#5\relax {#1#2#3#4\if\relax\detokenize{#5}\relax \expandafter\gobbleone \else \expandafter\firstofone \fi {\advance\pgpcount by 1 \ifnum\pgpcount=5 \par\pgpcount=0 \else\ \fi \dopgp#5\relax\unskip}} ...


4

Both answers here use not so optimal approach of parameter manipulation because the #5 parameter (the rest of the digits) is rewritten for each step in the loop. Better solution is: \newcount\tmpnum \def\pgp#1{\tmpnum=0 \pgpA #1 {}...} \def\pgpA#1#2#3#4{\ifx^#1^\unskip\else \ifnum\tmpnum=5\par\fi \advance\tmpnum by1 #1#2#3#4 ...


3

You need to tell TeX how many parameters (and maybe their separators) is provided by the defined macro. \def\alphabetExample#1{% {\fontfamily{#1}\selectfont Aa\-Bb\-Cc\-Dd\-Ee\-Ff\-Gg\-Hh\-Ii\-Jj\-Kk\-Ll% \-Mm\-Nn\-Oo\-Pp\-Qq\-Rr\-Ss\-Tt\-Uu\-Vv\-Ww\-Xx\-Yy\-Zz\-0123456789}}


3

Here's one way. Note that I've centred the title (I think) relative to the body of text which I took to be your intent. \documentclass{article} \usepackage{graphics,calc} \newsavebox{\modtitlebox} \newcommand{\modtitle}[2]{% \sbox{\modtitlebox}{% \begin{minipage}{\dimexpr1.25in+\textwidth} \vspace*{-5\baselineskip}% ...


3

I had to modify \getdata a bit to get it to work as a tikz parameter. \documentclass{amsart} \usepackage{tikz} \usepackage{xstring} \newcounter{comma} \newcommand{\colorstr}{}% reserve name \newcommand{\getcolor}[2][1]% #1 = index, #2 = array name {\ifnum#1=1\relax\StrBefore{#2}{,}[\colorstr]% \else\setcounter{comma}{#1}\addtocounter{comma}{-1}% ...


2

The above comment by John Kormylo, although so far I don't understand it, gave me a hint. He provided a link to an answer to another question; another answer to that question inspired this solution: \documentclass{amsart} \usepackage{tikz} \def\lesssillyexample#1#2{ \newcount\p \foreach\i in {#1} { \foreach\j in {1,...,\i} { \foreach[count=\k] ...


2

You combine the \newcommand syntax of parameter declarations with \xdef primitive. But primitive commands have normal and elegant syntax without square brackets. \def\createCMDM#1#2#3#4{% I don't understand why #3 is merged with #2 \expandafter\@ifdefinable\csname #3#2\endcsname{% \expandafter\gdef\csname #3#2\endcsname##1{% ...


2

Your problem is that you put the given space before #2, but you have to put the negative space after #2 in the \hbox to\hsize. (You can use \line instead \hbox to\hsize in plain TeX but you can't use this in LaTeX.) You can think about this: \newdimen\overmargin \overmargin=.625in \def\modtitle#1#2{% \vglue-5\baselineskip ...


1

You can try this: \def\addaction#1#2{% \ifx#2\undefined\else \expandafter\def\expandafter#2\expandafter{\expandafter#1#2}\fi} \def\resetEinstein{\def\Einstein{Albert Einstein (1879-1955)\xdef\Einstein{Einstein}}} \addaction\resetEinstein\chapter % in chapters \addaction\resetEinstein\section % in sections \addaction\resetEinstein\part % in parts ...


1

You need to load a font which actually has an upright \varepsilon. You could use the CMU Serif OpenType font in conjunction with xetex. \font\1="CMU Serif" \1 tex τεχ \bye


1

No need to redefine frame; if I understand your question correctly, you can use overlays and \mode. Here's a simple example document: \documentclass{beamer} %\documentclass{article} %\usepackage{beamerarticle} \begin{document} \begin{frame} \frametitle{% \mode<presentation>{% \only<1>{Title A}% \only<2>{Title B}% ...


1

Actually, what worked for me is an answer suggested by @eudoxos (he wrote it in the comments on my question) : \def\inserteq#1#2{\begin{equation}{#1}\label{#2}\end{equation}} I think this way is the simplest. Than you use it as: \inserteq{x+y=1}{eq1}


1

Perhaps using \rlapproduces what you want: \documentclass{article} \RequirePackage{graphics} \newcommand{\modtitle}[2]{% \vspace*{-5\baselineskip}\noindent\hspace*{-.75in}% \resizebox{\dimexpr1.25in+\linewidth}{!}{\textsc{#1}}\\% \hspace*{.1in}{\large \textsc{ \ \hfill \rlap{\hspace*{.625in} #2}}} \vspace{\baselineskip}\\ } ...


1

I think I've found the ultimate solution :) \documentclass{amsart} \usepackage{tikz} \newcount\positi \newcount\cumuli \def\finalexample#1#2{ \cumuli=0 \positi=0 \foreach\kthcolor[count=\k] in {#2}{ \ifnum\k>\cumuli \pgfmathparse{{#1}[\positi]} \let\curri\pgfmathresult \advance\cumuli by\curri \advance\positi by1 ...


1

This is not an answer to the specific question, but rather to the main problem. You have a database of the form \def\texti{Text for question 1} \def\textii{Text for question 2} ... \def\soli{Text for solution 1} \def\solii{Text for solution 2} ... You want to randomly extract some of the questions and relative answers, without repetition The following ...



Only top voted, non community-wiki answers of a minimum length are eligible