New answers tagged

1

This is perhaps too much, but I tried to use l3regex and checking whether the argument of #1 contains any non-digit using the 'negative class' [^0-9] as regular expression. A better approach would use a conditional, but until the context isn't clear, I restrict to this solution. \documentclass{article} \usepackage{xparse} \usepackage{l3regex} ...


3

Here's an alternative solution with a newcommand, if I understood what you want to do. Output Code \documentclass[margin=10pt]{standalone} \usepackage{tikz} \usetikzlibrary{positioning, shapes.geometric, arrows.meta} \tikzset{ connect/.style={-{Latex}}, } \newcommand\DrawStation[4][black]{% \begin{scope}[shift={(#3)}, #1] \draw (0,0) -- ++(2cm,0) ...


4

The best solution could be to use a pic which is something similar to \newcommand but for tikzpictures. It avoids nesting tikzpictures which is not recommended. Some more information abouts pics in: Can a shape be composed out of “subshapes” in TikZ? or What are the new features in TikZ/pgf 3.0? \documentclass[tikz]{standalone} \usepackage{tikz} ...


4

You can added numerical references using a combination of LaTeX3 \calc and refcount: \documentclass{article} \usepackage{enumitem} % Control enumerate's layout \usepackage{xparse,refcount} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff \newlist{myenumerate}{enumerate}{1} ...


4

I strongly recommend to use one of the existing classes, mentioned in the above comments. Personally I have had really good results with the exam class. Here's a example (in German). \documentclass[addpoints,a4paper,ngerman,12pt,answers]{exam} \usepackage{babel} \usepackage[a4paper,top=2.5cm,bottom=3cm,left=2.5cm,right=2cm]{geometry} ...


2

I was looking for a similar approach recently and my question was solved by using lua code within my document Using LuaLaTeX to calculate lengths in cm to be used in TikZ drawing. In the attached code I have a question regarding Magnetism and all numbers are randomly generated, which will in turn create a new question + answers. I also included some ...


1

Using the links provided in the comments, I was able to figure out a way to answer my own question that didn't require an external program: \begin{questions} %--- %\pgfmathsetseed{1} \pgfmathtruncatemacro\coeffa{random(1,10)} \pgfmathtruncatemacro\coeffb{random(2,8)} \pgfmathtruncatemacro\coeffc{\coeffa/gcd(\coeffa,\coeffb)} ...



Top 50 recent answers are included