~turminal/codetex

e3213a11de6fddffc239fd3ff0bca72cb6a05ab0 — Bor Grošelj Simić 1 year, 10 months ago 2d1571c
template for 2022/23
3 files changed, 83 insertions(+), 35 deletions(-)

D buildtex
M style.py -rw-r--r-- => -rwxr-xr-x
M tmplt.tex
D buildtex => buildtex +0 -30
@@ 1,30 0,0 @@
#!/bin/sh -ue

scriptname=$0

usage () {
	printf "Usage: %s <output> <preamble> [snippets] ...\n", "$scriptname"
}

[ -z "$1" ] && usage && exit 1
output=$1
[ -z "$2" ] && usage && exit 1
preamble=$2
shift 2

tmp=$(
  echo 'mkstemp(template)' |
    m4 -D template="${TMPDIR:-/tmp}/tmpXXXXXX"
)

cat "$preamble" > "$tmp"

for file in "$@"
do
	python3 style.py < "$file" >> "$tmp"
	printf "%svskip 3em\n" '\' >> "$tmp"
done

printf "%send{document}\n" '\' >> "$tmp"

mv "$tmp" "$output"

M style.py => style.py +1 -1
@@ 4,7 4,7 @@ from pygments import highlight
from pygments.formatters import LatexFormatter
from pygments.lexers.c_cpp import CppLexer
from pygments.style import Style
from pygments.token import (Keyword, Name, Comment, String, 
from pygments.token import (Keyword, Name, Comment, String,
     Number, Operator, Punctuation)

import sys

M tmplt.tex => tmplt.tex +82 -4
@@ 1,8 1,10 @@
\documentclass[a4paper, 12pt]{article}
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{color}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6.2in, 9in}]{geometry}
\usepackage[many]{tcolorbox}
\usetikzlibrary{calc}

\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%


@@ 96,8 98,84 @@
\def\PYZrb{]}
\makeatother

\definecolor{myblue}{RGB}{0,163,243}
\definecolor{myred}{RGB}{243, 10, 25}

\begin{document}
\tcbset{examplestyle/.style={
  breakable,
  enhanced,
  outer arc=4pt,
  arc=4pt,
  colframe=myblue,
  colback=myblue!20,
  attach boxed title to top left,
  boxed title style={
    colback=myblue,
    outer arc=4pt,
    arc=4pt,
    top=3pt,
    bottom=3pt,
    },
  fonttitle=\sffamily
  }
}

\tcbset{errorstyle/.style={
  breakable,
  enhanced,
  outer arc=4pt,
  arc=4pt,
  colframe=myred,
  colback=myred!20,
  attach boxed title to top left,
  boxed title style={
    colback=myred,
    outer arc=4pt,
    arc=4pt,
    top=3pt,
    bottom=3pt,
    },
  fonttitle=\sffamily
  }
}

\section*{}
\newtcolorbox[auto counter,number within=section]{examples}[1][]{
  examplestyle,
  colback=white,
  title=Dodatni primeri,
  overlay unbroken and first={
      \path
        let
        \p1=(title.north east),
        \p2=(frame.north east)
        in
        node[anchor=west,font=\sffamily,color=myblue,text width=\x2-\x1]
        at (title.east) {#1};
  }
}
\newtcolorbox[auto counter]{errors}[1][]{
  errorstyle,
  colback=white,
  title=Pogoste napake,
  overlay unbroken and first={
      \path
        let
        \p1=(title.north east),
        \p2=(frame.north east)
        in
        node[anchor=west,font=\sffamily,color=myblue,text width=\x2-\x1]
        at (title.east) {#1};
  }
}

\begin{document}
\\
\begin{examples}
test
\the\textwidth
\end{examples}
\begin{errors}[neki]
test
\end{errors}

\end{document}