Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions flows/jinja-yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,87 @@ pages:
- <regex>(?:linear\s+)?\s*map
- <case_sens_regex>(?: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/)

{% set preamble %}
% Author: Quintin Jean-Noël
% <http://moais.imag.fr/membres/jean-noel.quintin/>
\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
{% endset %}

<p align='middle' >
{% 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.
\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 %}
</p>

Hints: You can use Jinja ``set`` block to set variable ``foo``, then use ``foo`` as keyword argument for the ``latex`` macro.

choices:
- png
- jpg
- ~CORRECT~ svg
- bmp
- gif


completion_text: |

Expand Down