| 1 |
%% ----------------------------------------------------------------------------- |
| 2 |
%% 2017 por Fausto M. Lagos S. <[email protected]> |
| 3 |
%% |
| 4 |
%% Este trabajo puede ser distribuido o modificado bajo los |
| 5 |
%% términos y condiciones de la LaTeX Project Public License (LPPL) v1.3C, |
| 6 |
%% o cualquier versión posterior. La última versión de esta licencia |
| 7 |
%% puede verse en: |
| 8 |
%% http://www.latex-project.org/lppl.txt |
| 9 |
%% ----------------------------------------------------------------------------- |
| 10 |
%% Usted es libre de usarlo, modificarlo o distribuirlo siempre que se |
| 11 |
%% respeten los términos de la licencia y se reconozca al autor original |
| 12 |
%% ----------------------------------------------------------------------------- |
| 13 |
%% Este paquete le permite incluir código de Arduino o Processing en sus |
| 14 |
%% documentos LaTeX utilizando el resaltado de sintaxis propio de los |
| 15 |
%% respectivo IDE. |
| 16 |
%% ----------------------------------------------------------------------------- |
| 17 |
|
| 18 |
\NeedsTeXFormat{LaTeX2e} |
| 19 |
\ProvidesPackage{maker}[2017/06/09 maker LaTeX package] |
| 20 |
|
| 21 |
\RequirePackage{listings} |
| 22 |
\RequirePackage{tcolorbox} |
| 23 |
\tcbuselibrary{listings, skins} |
| 24 |
\RequirePackage{xcolor} |
| 25 |
\definecolor{arduino}{HTML}{00A3A9} |
| 26 |
\definecolor{processing}{HTML}{283362} |
| 27 |
\definecolor{structure}{HTML}{818A42} |
| 28 |
\definecolor{variables}{HTML}{128F8F} |
| 29 |
\definecolor{functions}{HTML}{DB6B21} |
| 30 |
\definecolor{back}{HTML}{E0E0E2} |
| 31 |
\definecolor{myblue}{rgb}{0.01,0.61,0.98} |
| 32 |
\definecolor{mygray}{rgb}{0.47,0.47,0.33} |
| 33 |
\definecolor{blueProcessing}{rgb}{0.01,0.61,0.98} |
| 34 |
\definecolor{orangeProcessing}{rgb}{0.8,0.4,0} |
| 35 |
\definecolor{greenProcessing}{rgb}{0,0.6,0} |
| 36 |
\definecolor{green2Processing}{HTML}{19A476} |
| 37 |
\definecolor{redProcessing}{rgb}{.95, .25, .2} |
| 38 |
\definecolor{constantProcessing}{rgb}{.45, .67, .75} |
| 39 |
|
| 40 |
\newcommand*{\FormatDigit}[1]{\ttfamily\textcolor{black}{#1}} |
| 41 |
%% http://tex.stackexchange.com/questions/32174/listings-package-how-can-i-format-all-numbers |
| 42 |
\lstdefinestyle{FormattedNumber}{% |
| 43 |
literate=*{0}{{\FormatDigit{0}}}{1}% |
| 44 |
{1}{{\FormatDigit{1}}}{1}% |
| 45 |
{2}{{\FormatDigit{2}}}{1}% |
| 46 |
{3}{{\FormatDigit{3}}}{1}% |
| 47 |
{4}{{\FormatDigit{4}}}{1}% |
| 48 |
{5}{{\FormatDigit{5}}}{1}% |
| 49 |
{6}{{\FormatDigit{6}}}{1}% |
| 50 |
{7}{{\FormatDigit{7}}}{1}% |
| 51 |
{8}{{\FormatDigit{8}}}{1}% |
| 52 |
{9}{{\FormatDigit{9}}}{1}% |
| 53 |
{.0}{{\FormatDigit{.0}}}{2}% |
| 54 |
{.1}{{\FormatDigit{.1}}}{2}% |
| 55 |
{.2}{{\FormatDigit{.2}}}{2}% |
| 56 |
{.3}{{\FormatDigit{.3}}}{2}% |
| 57 |
{.4}{{\FormatDigit{.4}}}{2}% |
| 58 |
{.5}{{\FormatDigit{.5}}}{2}% |
| 59 |
{.6}{{\FormatDigit{.6}}}{2}% |
| 60 |
{.7}{{\FormatDigit{.7}}}{2}% |
| 61 |
{.8}{{\FormatDigit{.8}}}{2}% |
| 62 |
{.9}{{\FormatDigit{.9}}}{2}% |
| 63 |
%{,}{{\FormatDigit{,}}{1}% Eliminar el comentario si quiere "," en color |
| 64 |
{\ }{{ }}{1}% |
| 65 |
,% |
| 66 |
} |
| 67 |
|
| 68 |
%Arduino |
| 69 |
\DeclareOption{arduino}{% |
| 70 |
\lstdefinelanguage{arduino}{ |
| 71 |
basicstyle=\footnotesize, |
| 72 |
breakatwhitespace=false, |
| 73 |
breaklines=true, |
| 74 |
captionpos=b, |
| 75 |
commentstyle=\color{gray}, |
| 76 |
deletekeywords={...}, |
| 77 |
escapeinside={\%*}{*)}, |
| 78 |
extendedchars=true, |
| 79 |
keepspaces=true, |
| 80 |
keywordstyle=[1]\color{structure}, |
| 81 |
keywordstyle=[2]\color{variables}, |
| 82 |
keywordstyle=[3]\color{functions}, |
| 83 |
keywordstyle=[4]\bfseries\color{functions}, |
| 84 |
morekeywords={*,...}, |
| 85 |
numbers=left, |
| 86 |
numbersep=5pt, |
| 87 |
numberstyle=\tiny\color{mygray}, |
| 88 |
rulecolor=\color{black}, |
| 89 |
rulesepcolor=\color{myblue}, |
| 90 |
showspaces=false, |
| 91 |
showstringspaces=false, |
| 92 |
showtabs=false, |
| 93 |
stringstyle=\color{rgb: red,0.33;green,0.45;blue,0.87}, |
| 94 |
tabsize=2, |
| 95 |
emphstyle=\color{variables}, |
| 96 |
} |
| 97 |
|
| 98 |
\lstdefinestyle{Arduino}{% |
| 99 |
language=arduino, |
| 100 |
style=FormattedNumber, |
| 101 |
keywords={setup, loop, if, else, for, switch, while, do, break, continue, return, goto}, |
| 102 |
morekeywords=[2]{HIGH, LOW, INPUT, OUTPUT, INPUT_PULLUP, LED_BUILTIN, true, false, % |
| 103 |
int, float, void, boolean, char, word, long, short, double, string, array}, |
| 104 |
morekeywords=[3]{const, pinMode, digitalWrite, digitalRead, analogReference, % |
| 105 |
analogRead, analogWrite, analogReadResolution, analogWriteResolution, tone, noTone, % |
| 106 |
shiftOut, shiftIn, pulseIn, millis, micros, delay, delayMicroseconds, min, max, abs, % |
| 107 |
constrain, map, pow, sqrt, sin, cos, tan, isAlphaNumeric, inAlpha, isAscii, isWhitespace, % |
| 108 |
isControl, isDigit, isGraph, isLowerCase, isPintable, isPunct, isSpace, isUpperCase, % |
| 109 |
isHexadecimalDigit, randomSeed, random, lowByte, highByte, bitRead, bitWrite, bitSet, % |
| 110 |
bitClear, bit, attachInterrupt, detachInterrupt, interrupts, noInterrupts, Stream, % |
| 111 |
Keyboard, Mouse, begin, println, print}, |
| 112 |
morekeywords=[4]{Serial}, |
| 113 |
morecomment=[l]{//}, |
| 114 |
morecomment=[s]{/*}{*/}, |
| 115 |
emph={const}, |
| 116 |
} |
| 117 |
|
| 118 |
% Comando para incluir un sketch de Arduino, el primer parámetro es el nombre del archivo que contiene el script (sin .ino), el segundo es el etiqueta del contador Listing |
| 119 |
\newcommand{\ArduinoSketch}[2]{ |
| 120 |
\begin{itemize} |
| 121 |
\item[]\lstinputlisting[language=arduino,caption=#2,label=#1,style=Arduino,frame=single, % |
| 122 |
framexleftmargin=15pt,rulecolor=\color{arduino},framerule=1pt]{#1.ino} |
| 123 |
\end{itemize} |
| 124 |
} |
| 125 |
|
| 126 |
% Ambiente para incluir un sketch de Arduino escribiendo el código directamente en el documento LaTeX, tiene un parámetro de entrada que corresponde al título del sketch |
| 127 |
\newtcblisting{ArduinoSketchBox}[2][colframe = arduino, enhanced, drop shadow, hbox]{ |
| 128 |
arc = 3pt, outer arc = 3pt, |
| 129 |
listing only, |
| 130 |
listing options = { |
| 131 |
language = arduino, |
| 132 |
style = Arduino, |
| 133 |
}, |
| 134 |
title = #2, |
| 135 |
#1 |
| 136 |
} |
| 137 |
|
| 138 |
\newcommand{\ArduinoInline}[1]{ |
| 139 |
\lstinline[language=arduino,style=Arduino]{#1} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
%Processing |
| 144 |
\DeclareOption{processing}{ |
| 145 |
\lstdefinelanguage{processing}{ |
| 146 |
basicstyle=\footnotesize, |
| 147 |
breakatwhitespace=false, |
| 148 |
breaklines=true, |
| 149 |
captionpos=b, |
| 150 |
commentstyle=\color{gray}, |
| 151 |
deletekeywords={...}, |
| 152 |
escapeinside={\%*}{*)}, |
| 153 |
extendedchars=true, |
| 154 |
keepspaces=true, |
| 155 |
keywordstyle=[1]\color{blueProcessing}, |
| 156 |
keywordstyle=[2]\bfseries\color{blueProcessing}, |
| 157 |
keywordstyle=[3]\color{orangeProcessing}, |
| 158 |
keywordstyle=[4]\color{greenProcessing}, |
| 159 |
keywordstyle=[5]\color{redProcessing}, |
| 160 |
keywordstyle=[6]\color{constantProcessing}, |
| 161 |
keywordstyle=[7]\color{green2Processing}, |
| 162 |
morekeywords={*,...}, |
| 163 |
numbers=left, |
| 164 |
numbersep=5pt, |
| 165 |
numberstyle=\tiny\color{mygray}, |
| 166 |
rulecolor=\color{black}, |
| 167 |
rulesepcolor=\color{myblue}, |
| 168 |
showspaces=false, |
| 169 |
showstringspaces=false, |
| 170 |
showtabs=false, |
| 171 |
stringstyle=\color{rgb: red,0.33;green,0.45;blue,0.87}, |
| 172 |
tabsize=2, |
| 173 |
emphstyle=\color{blue}, |
| 174 |
} |
| 175 |
|
| 176 |
\lstdefinestyle{Processing}{% |
| 177 |
language=processing, |
| 178 |
style=FormattedNumber, |
| 179 |
keywords={size, exit, loop, noLoop, popStyle, background, pushStyle, fill, % |
| 180 |
noFill, stroke, strokeWeight, noStroke, line, triangle, quad, rect, arc, ellipse, % |
| 181 |
frameRate, random, cos, sin, second, minute, hour, println, loadImage, image, % |
| 182 |
sqrt, sq, printArray, list, createFont, length, redraw, % |
| 183 |
thread, cursor, delay, displayDensity, frameRate, fullScreen, noCursor, noSmooth, % |
| 184 |
pixelDensity, smooth, str, hex, binary, unbinary, unhex, join, match, matchAll, % |
| 185 |
nf, nfc, nfp, nfs, split, splitTokens, trim, append, arrayCopy, concat, expand, % |
| 186 |
reverse, shorten, sort, splice, subset, createShape, loadShape, point, quad, rect, % |
| 187 |
bezier, bezierDetail, bezierPoint, bezierTangent, curve, curveDetail, curvePoint, % |
| 188 |
curveTangent, curveTightness, box, sphere, sphereDetail, ellipseMode, rectMode, % |
| 189 |
strokeCap, strokeJoin, strokeWeight, beginContour, beginShape, bezierVertex, % |
| 190 |
endContour, endShape, quadraticVertex, vertex, shape, shapeMode, createInput, % |
| 191 |
createReader, launch, loadBytes, loadJSONArray, loadJSONObject, loadStrings, % |
| 192 |
loadTable, loadXML, parseJSONArray, parseJSONObject, parseXML, selectFolder, % |
| 193 |
selectInput, day, hour, millis, minute, month, second, year, print, printArray, % |
| 194 |
println, save, saveFrame, beginRaw, beginRecord, createOutput, createWriter, % |
| 195 |
endRaw, endRecord, saveBytes, saveJSONArray, saveJSONObject, saveStream, % |
| 196 |
saveStrings, saveTable, saveXML, selectOutput, applyMatrix, popMatrix, printMatrix, % |
| 197 |
pushMatrix, resetMatrix, rotate, rotateX, rotateY, rotateZ, scale, shearX, shearY, % |
| 198 |
translate, ambientLight, directionalLight, lightFalloff, lights, lightSpecular, % |
| 199 |
noLights, normal, pointLight, spotLight, beginCamera, camera, endCamera, frustum, % |
| 200 |
ortho, perspective, printCamera, printProjection, modelX, modelY, modelZ, % |
| 201 |
screenX, screenY, screenZ, ambient, emmisive, shininess, specular, clear, % |
| 202 |
colorMode, alpha, blue, brightness, color, green, hue, lerpColor, red, saturationx % |
| 203 |
createImage, imageMode, noTint, requestImage, tint, texture, textureMode, % |
| 204 |
textureWrap, blend, copy, filter, get, loadPixels, set, updatePixels, blendMode, % |
| 205 |
clip, createGraphics, noClip, loadShader, resetShader, shader, createFont, % |
| 206 |
loadFont, text, textFont, textAlign, textLeading, textMode, textSize, textWidth, % |
| 207 |
textAscent, textDescent, abs, ceil, constrain, dist, exp, floor, lerp, log, % |
| 208 |
mag, max, min, norm, pow, round, sq, sqrt, acos, asin, atan, atan2, degrees, radians, % |
| 209 |
tan, noise, noiseDetail, noiseSeed, randomGaussian, randomSeed},% define keywords |
| 210 |
morekeywords=[2]{setup, draw, keyPressed, settings, mouseClicked, mouseDragged, % |
| 211 |
mouseMoved, mousePressed, mouseReleased, mouseWheel, keyPressed, keyReleased, % |
| 212 |
keyTyped}, |
| 213 |
morekeywords=[3]{color, int, float, PImage, String, boolean, PFont, byte, char, % |
| 214 |
double, long, Array, ArrayList, FloatDict, FloatList, HashMap, IntDict, IntList, % |
| 215 |
JSONArray, JSONObject, String, StringDict, StringList, Table, TableRow, XML, % |
| 216 |
BufferedReader, PrintWriter, pixels, PGraphics, PShader, PFont, PVector}, |
| 217 |
morekeywords=[4]{while, if, for, else, RIGHT, LEFT, catch, try, switch}, |
| 218 |
morekeywords=[5]{height, width, mouseX, mouseY, keyCode, focused, frameCount, % |
| 219 |
frameRate, mousePressed, pixelHeight, pixelWidth, PShape, mouseButton, mouseX, % |
| 220 |
mouseY, pmouseX, pmouseY, key, keyCode}, |
| 221 |
morekeywords=[6]{PI, HALF_PI, QUARTER_PI, TAU, TWO_PI}, |
| 222 |
morekeywords=[7]{extends, class, final, implements, import, new, null, private, % |
| 223 |
public, return, static, super, this, false, true, void, break, case, continue, % |
| 224 |
default}, |
| 225 |
morecomment=[l]{//}, |
| 226 |
morecomment=[s]{/*}{*/}, |
| 227 |
emph={HIGH, OUTPUT, LOW}, |
| 228 |
} |
| 229 |
|
| 230 |
\newcommand{\ProcessingSketch}[2]{ |
| 231 |
\begin{itemize} |
| 232 |
\item[]\lstinputlisting[language=Processing,caption=#2,label=#1,style=Processing, % |
| 233 |
frame=single,framexleftmargin=15pt,rulecolor=\color{processing},framerule=1pt]{#1.pde} |
| 234 |
\end{itemize} |
| 235 |
} |
| 236 |
|
| 237 |
\newtcblisting{ProcessingSketchBox}[2][colframe = processing, enhanced, drop shadow, hbox]{ |
| 238 |
arc = 3pt, outer arc = 3pt, |
| 239 |
listing only, |
| 240 |
listing options = { |
| 241 |
language = processing, |
| 242 |
style = Processing, |
| 243 |
}, |
| 244 |
title = #2, |
| 245 |
#1 |
| 246 |
} |
| 247 |
|
| 248 |
\newcommand{\ProcessingInline}[1]{ |
| 249 |
\lstinline[language=processing,style=Processing]{#1} |
| 250 |
} |
| 251 |
} |
| 252 |
\ProcessOptions\relax |
| 253 |
|
| 254 |
\endinput |