From ccd55e3dd610d1bd643a5daae28c9090cbd24bdc Mon Sep 17 00:00:00 2001 From: ifaint Date: Thu, 5 May 2016 22:34:38 +0800 Subject: [PATCH 1/3] added tex2img example. --- flows/jinja-yaml.yml | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/flows/jinja-yaml.yml b/flows/jinja-yaml.yml index 1d7011b..4028ed2 100644 --- a/flows/jinja-yaml.yml +++ b/flows/jinja-yaml.yml @@ -38,6 +38,85 @@ pages: - (?:linear\s+)?\s*map - (?:operator\s+)?\s*map +- + type: ChoiceQuestion + id: latex_image + title: Latex 2 image + value: 2 + prompt: | + + # Choice + + What format is the following image? From + [TEXexample.net](http://www.texample.net/tikz/examples/complete-graph/) + +

+ {% call latex(image_format="png", is_full_code=True) %} + % Author: Quintin Jean-Noël + % + \documentclass{article} + \usepackage[fontsize=14px]{scrextend} % render with font size 14px + \usepackage{tikz} + %%%< + \usepackage{verbatim} + % The following three lines must be commented. + %\usepackage[active,tightpage]{preview} + %\PreviewEnvironment{tikzpicture} + %\setlength\PreviewBorder{5pt}% + %%%> + \begin{comment} + :Title: A complete graph + :Tags: Foreach;Graphs;To paths + :Author: Jean-Noël Quintin + :Slug: complete-graph + \end{comment} + \usetikzlibrary[topaths] + % A counter, since TikZ is not clever enough (yet) to handle + % arbitrary angle systems. + \newcount\mycount + \begin{document} + \begin{tikzpicture}[transform shape] + %the multiplication with floats is not possible. Thus I split the loop in two. + \foreach \number in {1,...,8}{ + % Computer angle: + \mycount=\number + \advance\mycount by -1 + \multiply\mycount by 45 + \advance\mycount by 0 + \node[draw,circle,inner sep=0.25cm] (N-\number) at (\the\mycount:5.4cm) {}; + } + \foreach \number in {9,...,16}{ + % Computer angle: + \mycount=\number + \advance\mycount by -1 + \multiply\mycount by 45 + \advance\mycount by 22.5 + \node[draw,circle,inner sep=0.25cm] (N-\number) at (\the\mycount:5.4cm) {}; + } + \foreach \number in {1,...,15}{ + \mycount=\number + \advance\mycount by 1 + \foreach \numbera in {\the\mycount,...,16}{ + \path (N-\number) edge[->,bend right=3] (N-\numbera) edge[<-,bend + left=3] (N-\numbera); + } + } + \end{tikzpicture} + \end{document} + {% endcall %} +

+ + Hints: You can use Jinja ``set`` block to set variable ``foo``, then use ``foo`` as (k)argument for the ``latex`` macro. + + + + choices: + - png + - jpg + - ~CORRECT~ svg + - bmp + - gif + completion_text: | From 4ccf7134aed68ed9200eef883246947db4eac7ab Mon Sep 17 00:00:00 2001 From: ifaint Date: Fri, 6 May 2016 17:45:47 +0800 Subject: [PATCH 2/3] remove is_full_code arg. --- flows/jinja-yaml.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flows/jinja-yaml.yml b/flows/jinja-yaml.yml index 4028ed2..ab5f831 100644 --- a/flows/jinja-yaml.yml +++ b/flows/jinja-yaml.yml @@ -51,7 +51,7 @@ pages: [TEXexample.net](http://www.texample.net/tikz/examples/complete-graph/)

- {% call latex(image_format="png", is_full_code=True) %} + {% call latex(image_format="png") %} % Author: Quintin Jean-Noël % \documentclass{article} @@ -106,7 +106,7 @@ pages: {% endcall %}

- Hints: You can use Jinja ``set`` block to set variable ``foo``, then use ``foo`` as (k)argument for the ``latex`` macro. + Hints: You can use Jinja ``set`` block to set variable ``foo``, then use ``foo`` as (key) argument for the ``latex`` macro. From 2635b2c2bd2986e26e59ae6c61ac132bc81d857a Mon Sep 17 00:00:00 2001 From: ifaint Date: Tue, 31 May 2016 23:14:00 +0800 Subject: [PATCH 3/3] update along with https://github.com/inducer/relate/pull/207 --- flows/jinja-yaml.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/flows/jinja-yaml.yml b/flows/jinja-yaml.yml index ab5f831..6d370ce 100644 --- a/flows/jinja-yaml.yml +++ b/flows/jinja-yaml.yml @@ -46,12 +46,11 @@ pages: prompt: | # Choice - + What format is the following image? From [TEXexample.net](http://www.texample.net/tikz/examples/complete-graph/) - -

- {% call latex(image_format="png") %} + + {% set preamble %} % Author: Quintin Jean-Noël % \documentclass{article} @@ -74,6 +73,11 @@ pages: % A counter, since TikZ is not clever enough (yet) to handle % arbitrary angle systems. \newcount\mycount + {% endset %} + +

+ {% call latex(compiler="latex", tex_preamble=preamble, image_format="png") %} + \begin{document} \begin{tikzpicture}[transform shape] %the multiplication with floats is not possible. Thus I split the loop in two. @@ -105,10 +109,8 @@ pages: \end{document} {% endcall %}

- - Hints: You can use Jinja ``set`` block to set variable ``foo``, then use ``foo`` as (key) argument for the ``latex`` macro. - + Hints: You can use Jinja ``set`` block to set variable ``foo``, then use ``foo`` as keyword argument for the ``latex`` macro. choices: - png