Algo1Macros.tex 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. \usepackage{ifthen}
  2. \usepackage{amssymb}
  3. \usepackage{multicol}
  4. \usepackage{graphicx}
  5. \usepackage[absolute]{textpos}
  6. \makeatletter
  7. \@ifclassloaded{beamer}{%
  8. \newcommand{\tocarEspacios}{%
  9. \addtolength{\leftskip}{4em}%
  10. \addtolength{\parindent}{-3em}%
  11. }%
  12. }
  13. {%
  14. \usepackage[top=1cm,bottom=2cm,left=1cm,right=1cm]{geometry}%
  15. \usepackage{color}%
  16. \newcommand{\tocarEspacios}{%
  17. \addtolength{\leftskip}{5em}%
  18. \addtolength{\parindent}{-3em}%
  19. }%
  20. }
  21. \newcommand{\encabezadoDeProblema}[4]{%
  22. % Ponemos la palabrita problema en tt
  23. % \noindent%
  24. {\normalfont\bfseries\ttfamily problema}%
  25. % Ponemos el nombre del problema
  26. \ %
  27. {\normalfont\ttfamily #2}%
  28. \
  29. % Ponemos los parametros
  30. (#3)%
  31. \ifthenelse{\equal{#4}{}}{}{%
  32. \ =\ %
  33. % Ponemos el nombre del resultado
  34. {\normalfont\ttfamily #1}%
  35. % Por ultimo, va el tipo del resultado
  36. \ : #4}
  37. }
  38. \newcommand{\encabezadoDeTipo}[2]{%
  39. % Ponemos la palabrita tipo en tt
  40. {\normalfont\bfseries\ttfamily tipo}%
  41. % Ponemos el nombre del tipo
  42. \ %
  43. {\normalfont\ttfamily #2}%
  44. \ifthenelse{\equal{#1}{}}{}{$\langle$#1$\rangle$}
  45. }
  46. % Primero definiciones de cosas al estilo title, author, date
  47. \def\materia#1{\gdef\@materia{#1}}
  48. \def\@materia{No especifi\'o la materia}
  49. \def\lamateria{\@materia}
  50. \def\cuatrimestre#1{\gdef\@cuatrimestre{#1}}
  51. \def\@cuatrimestre{No especifi\'o el cuatrimestre}
  52. \def\elcuatrimestre{\@cuatrimestre}
  53. \def\anio#1{\gdef\@anio{#1}}
  54. \def\@anio{No especifi\'o el anio}
  55. \def\elanio{\@anio}
  56. \def\fecha#1{\gdef\@fecha{#1}}
  57. \def\@fecha{\today}
  58. \def\lafecha{\@fecha}
  59. \def\nombre#1{\gdef\@nombre{#1}}
  60. \def\@nombre{No especific'o el nombre}
  61. \def\elnombre{\@nombre}
  62. \def\practicas#1{\gdef\@practica{#1}}
  63. \def\@practica{No especifi\'o el n\'umero de pr\'actica}
  64. \def\lapractica{\@practica}
  65. % Esta macro convierte el numero de cuatrimestre a palabras
  66. \newcommand{\cuatrimestreLindo}{
  67. \ifthenelse{\equal{\elcuatrimestre}{1}}
  68. {Primer cuatrimestre}
  69. {\ifthenelse{\equal{\elcuatrimestre}{2}}
  70. {Segundo cuatrimestre}
  71. {Verano}}
  72. }
  73. \newcommand{\depto}{{UBA -- Facultad de Ciencias Exactas y Naturales --
  74. Departamento de Computaci\'on}}
  75. \newcommand{\titulopractica}{
  76. \centerline{\depto}
  77. \vspace{1ex}
  78. \centerline{{\Large\lamateria}}
  79. \vspace{0.5ex}
  80. \centerline{\cuatrimestreLindo de \elanio}
  81. \vspace{2ex}
  82. \centerline{{\huge Pr\'actica \lapractica -- \elnombre}}
  83. \vspace{5ex}
  84. \arreglarincisos
  85. \newcounter{ejercicio}
  86. \newenvironment{ejercicio}{\stepcounter{ejercicio}\textbf{Ejercicio
  87. \theejercicio}%
  88. \renewcommand\@currentlabel{\theejercicio}%
  89. }{\vspace{0.2cm}}
  90. }
  91. \newcommand{\titulotp}{
  92. \centerline{\depto}
  93. \vspace{1ex}
  94. \centerline{{\Large\lamateria}}
  95. \vspace{0.5ex}
  96. \centerline{\cuatrimestreLindo de \elanio}
  97. \vspace{0.5ex}
  98. \centerline{\lafecha}
  99. \vspace{2ex}
  100. \centerline{{\huge\elnombre}}
  101. \vspace{5ex}
  102. }
  103. %practicas
  104. \newcommand{\practica}[2]{%
  105. \title{Pr\'actica #1 \\ #2}
  106. \author{Algoritmos y Estructuras de Datos I}
  107. \date{Segundo Cuatrimestre 2015}
  108. \maketitlepractica{#1}{#2}
  109. }
  110. % Seteo el numero de cuatrimestre y anio para que lo ponga lindo
  111. \cuatrimestre{2}
  112. \anio{2016}
  113. \newcommand \maketitlepractica[2] {%
  114. \begin{center}
  115. \begin{tabular}{r cr}
  116. \begin{tabular}{c}
  117. {\large\bf\textsf{\ Algoritmos y Estructuras de Datos I\ }}\\
  118. \cuatrimestreLindo de \elanio\\
  119. \title{\normalsize Gu\'ia Pr\'actica #1 \\ \textbf{#2}}\\
  120. \@title
  121. \end{tabular} &
  122. \begin{tabular}{@{} p{1.6cm} @{}}
  123. \includegraphics[width=1.6cm]{logodpt.jpg}
  124. \end{tabular} &
  125. \begin{tabular}{l @{}}
  126. \emph{Departamento de Computaci\'on} \\
  127. \emph{Facultad de Ciencias Exactas y Naturales} \\
  128. \emph{Universidad de Buenos Aires} \\
  129. \end{tabular}
  130. \end{tabular}
  131. \end{center}
  132. \bigskip
  133. }
  134. % Simbolos varios
  135. \newcommand{\ent}{\ensuremath{\mathbb{Z}}}
  136. \newcommand{\float}{\ensuremath{\mathbb{R}}}
  137. \newcommand{\bool}{\ensuremath{\mathsf{Bool}}}
  138. \newcommand{\True}{\ensuremath{\mathrm{True}}}
  139. \newcommand{\False}{\ensuremath{\mathrm{False}}}
  140. \newcommand{\Then}{\ensuremath{\rightarrow}}
  141. \newcommand{\Iff}{\ensuremath{\leftrightarrow}}
  142. \newcommand{\implica}{\ensuremath{\longrightarrow}}
  143. \newcommand{\IfThenElse}[3]{\ensuremath{\mathsf{if}\ #1\ \mathsf{then}\ #2\ \mathsf{else}\ #3}}
  144. \newcommand{\rango}[2]{[#1\twodots#2]}
  145. \newcommand{\comp}[2]{[\,#1\,|\,#2\,]}
  146. \newcommand{\rangoac}[2]{(#1\twodots#2]}
  147. \newcommand{\rangoca}[2]{[#1\twodots#2)}
  148. \newcommand{\rangoaa}[2]{(#1\twodots#2)}
  149. %ejercicios
  150. \newtheorem{exercise}{Ejercicio}
  151. \newenvironment{ejercicio}{\begin{exercise}\rm}{\end{exercise} \vspace{0.2cm}}
  152. \newenvironment{items}{\begin{enumerate}[i)]}{\end{enumerate}}
  153. \newenvironment{subitems}{\begin{enumerate}[a)]}{\end{enumerate}}
  154. \newcommand{\sugerencia}[1]{\noindent \textbf{Sugerencia:} #1}
  155. %tipos basicos
  156. \newcommand{\rea}{\ensuremath{\mathsf{Float}}}
  157. \newcommand{\cha}{\ensuremath{\mathsf{Char}}}
  158. \newcommand{\mcd}{\mathrm{mcd}}
  159. \newcommand{\prm}[1]{\ensuremath{\mathsf{prm}(#1)}}
  160. \newcommand{\sgd}[1]{\ensuremath{\mathsf{sgd}(#1)}}
  161. %listas
  162. \newcommand{\TLista}[1]{[#1]}
  163. \newcommand{\lvacia}{\ensuremath{[\ ]}}
  164. \newcommand{\lv}{\ensuremath{[\ ]}}
  165. \newcommand{\longitud}[1]{\left| #1 \right|}
  166. \newcommand{\cons}[1]{\ensuremath{\mathsf{cons}}(#1)}
  167. \newcommand{\indice}[1]{\ensuremath{\mathsf{indice}}(#1)}
  168. \newcommand{\conc}[1]{\ensuremath{\mathsf{conc}}(#1)}
  169. \newcommand{\cab}[1]{\ensuremath{\mathsf{cab}}(#1)}
  170. \newcommand{\cola}[1]{\ensuremath{\mathsf{cola}}(#1)}
  171. \newcommand{\sub}[1]{\ensuremath{\mathsf{sub}}(#1)}
  172. \newcommand{\en}[1]{\ensuremath{\mathsf{en}}(#1)}
  173. \newcommand{\cuenta}[2]{\mathsf{cuenta}\ensuremath{(#1, #2)}}
  174. \newcommand{\suma}[1]{\mathsf{suma}(#1)}
  175. \newcommand{\twodots}{\ensuremath{\mathrm{..}}}
  176. \newcommand{\masmas}{\ensuremath{++}}
  177. % Acumulador
  178. \newcommand{\acum}[1]{\ensuremath{\mathsf{acum}}(#1)}
  179. \newcommand{\acumselec}[3]{\ensuremath{\mathrm{acum}(#1 | #2, #3)}}
  180. % \selector{variable}{dominio}
  181. \newcommand{\selector}[2]{#1~\ensuremath{\leftarrow}~#2}
  182. \newcommand{\selec}{\ensuremath{\leftarrow}}
  183. \newenvironment{problema}[4][res]{%
  184. % El parametro 1 (opcional) es el nombre del resultado
  185. % El parametro 2 es el nombre del problema
  186. % El parametro 3 son los parametros
  187. % El parametro 4 es el tipo del resultado
  188. % Preambulo del ambiente problema
  189. % Tenemos que definir los comandos requiere, asegura, modifica y aux
  190. \newcommand{\requiere}[2][]{%
  191. {\normalfont\bfseries\ttfamily requiere}%
  192. \ifthenelse{\equal{##1}{}}{}{\ {\normalfont\ttfamily ##1} :}\ %
  193. \ensuremath{##2}%
  194. {\normalfont\bfseries\,;\par}%
  195. }
  196. \newcommand{\asegura}[2][]{%
  197. {\normalfont\bfseries\ttfamily asegura}%
  198. \ifthenelse{\equal{##1}{}}{}{\ {\normalfont\ttfamily ##1} :}\
  199. \ensuremath{##2}%
  200. {\normalfont\bfseries\,;\par}%
  201. }
  202. \newcommand{\modifica}[1]{%
  203. {\normalfont\bfseries\ttfamily modifica\ }%
  204. \ensuremath{##1}%
  205. {\normalfont\bfseries\,;\par}%
  206. }
  207. \renewcommand{\aux}[4]{%
  208. {\normalfont\bfseries\ttfamily aux\ }%
  209. {\normalfont\ttfamily ##1}%
  210. \ifthenelse{\equal{##2}{}}{}{\ (##2)}\ : ##3\, = \ensuremath{##4}%
  211. {\normalfont\bfseries\,;\par}%
  212. }
  213. \newcommand{\res}{#1}
  214. \vspace{1ex}
  215. \noindent
  216. \encabezadoDeProblema{#1}{#2}{#3}{#4}
  217. % Abrimos la llave
  218. \{\par%
  219. \tocarEspacios
  220. }
  221. % Ahora viene el cierre del ambiente problema
  222. {
  223. % Cerramos la llave
  224. \noindent\}
  225. \vspace{1ex}
  226. }
  227. \newcommand{\aux}[4]{%
  228. {\normalfont\bfseries\ttfamily aux\ }%
  229. {\normalfont\ttfamily #1}%
  230. \ifthenelse{\equal{#2}{}}{}{\ (#2)}\ : #3\, = \ensuremath{#4}%
  231. {\normalfont\bfseries\,;\par}%
  232. }
  233. \newcommand{\pre}[1]{\textsf{pre}\ensuremath{(#1)}}
  234. \newcommand{\problemanom}[1]{\textsf{#1}}
  235. \newcommand{\problemail}[3]{\textsf{problema #1}\ensuremath{(#2) = #3}}
  236. \newcommand{\problemailsinres}[2]{\textsf{problema #1}\ensuremath{(#2)}}
  237. \newcommand{\requiereil}[2]{\textsf{requiere #1: }\ensuremath{#2}}
  238. \newcommand{\asegurail}[2]{\textsf{asegura #1: }\ensuremath{#2}}
  239. \newcommand{\modificail}[1]{\textsf{modifica }\ensuremath{#1}}
  240. \newcommand{\auxil}[2]{\textsf{aux }\ensuremath{#1 = #2}}
  241. \newcommand{\auxilc}[4]{\textsf{aux }\ensuremath{#1( #2 ): #3 = #4}}
  242. \newcommand{\auxnom}[1]{\textsf{aux }\ensuremath{#1}}
  243. \newcommand{\comentario}[1]{{/*\ #1\ */}}
  244. \newcommand{\nom}[1]{\ensuremath{\mathsf{#1}}}
  245. % -----------------
  246. % Tipos compuestos
  247. % -----------------
  248. \newcommand{\Pred}[1]{\mathit{#1}}
  249. \newcommand{\TSet}[1]{\textsf{Conjunto}\ensuremath{\langle #1 \rangle}}
  250. \newcommand{\TSetFinito}[1]{\textsf{Conjunto}\ensuremath{\langle #1 \rangle}}
  251. \newcommand{\TRac}{\tiponom{Racional}}
  252. \newcommand{\TVec}{\tiponom{Vector}}
  253. \newcommand{\Func}[1]{\mathrm{#1}}
  254. \newcommand{\cardinal}[1]{\left| #1 \right|}
  255. \newcommand{\sinonimo}[2]{%
  256. \noindent%
  257. {\normalfont\bfseries\ttfamily tipo\ }%
  258. #1\ =\ #2%
  259. {\normalfont\bfseries\,;\par}
  260. }
  261. \newcommand{\enum}[2]{%
  262. \noindent%
  263. {\normalfont\bfseries\ttfamily tipo\ }%
  264. #1\ =\ #2%
  265. {\normalfont\bfseries\,;\par}
  266. }
  267. %~ \newenvironment{tipo}[1]{%
  268. %~ \vspace{0.2cm}
  269. %~ \textsf{tipo #1}\ensuremath{\{}\\
  270. %~ \begin{tabular}[l]{p{0.02\textwidth} p{0.02\textwidth} p{0.82 \textwidth}}
  271. %~ }{%
  272. %~ \end{tabular}
  273. %~
  274. %~ \ensuremath{\}}
  275. %~ \vspace{0.15cm}
  276. %~ }
  277. %~
  278. \newenvironment{tipo}[2][]{%
  279. % Preambulo del ambiente tipo
  280. % Tenemos que definir los comandos observador (con requiere) y aux
  281. \newcommand{\observador}[3]{%
  282. {\normalfont\bfseries\ttfamily observador\ }%
  283. {\normalfont\ttfamily ##1}%
  284. \ifthenelse{\equal{##2}{}}{}{\ (##2)}\ : ##3%
  285. {\normalfont\bfseries\,;\par}%
  286. }
  287. \newcommand{\requiere}[2][]{{%
  288. \addtolength{\leftskip}{3em}%
  289. \setlength{\parindent}{-2em}%
  290. {\normalfont\bfseries\ttfamily requiere}%
  291. \ifthenelse{\equal{##1}{}}{}{\ {\normalfont\ttfamily ##1} :}\
  292. \ensuremath{##2}%
  293. {\normalfont\bfseries\,;\par}}
  294. }
  295. \newcommand{\explicacion}[1]{{%
  296. \addtolength{\leftskip}{3em}%
  297. \setlength{\parindent}{-2em}%
  298. \par \hspace{2.3em} ##1 %
  299. {\par}
  300. }
  301. }
  302. \newcommand{\invariante}[2][]{%
  303. {\normalfont\bfseries\ttfamily invariante}%
  304. \ifthenelse{\equal{##1}{}}{}{\ {\normalfont\ttfamily ##1} :}\
  305. \ensuremath{##2}%
  306. {\normalfont\bfseries\,;\par}%
  307. }
  308. \renewcommand{\aux}[4]{%
  309. {\normalfont\bfseries\ttfamily aux\ }%
  310. {\normalfont\ttfamily ##1}%
  311. \ifthenelse{\equal{##2}{}}{}{\ (##2)}\ : ##3\, = \ensuremath{##4}%
  312. {\normalfont\bfseries\,;\par}%
  313. }
  314. \vspace{1ex}
  315. \noindent
  316. \encabezadoDeTipo{#1}{#2}
  317. % Abrimos la llave
  318. \{\par%
  319. \tocarEspacios
  320. }
  321. % Ahora viene el cierre del ambiente tipo
  322. {
  323. % Cerramos la llave
  324. \noindent\}
  325. \vspace{1ex}
  326. }
  327. %~ \newcommand{\observador}[3]{%
  328. %~ & \multicolumn{2}{p{0.85\textwidth}}{\textsf{observador #1}\ensuremath{(#2):#3}}\\%
  329. %~ }
  330. %~ \newcommand{\observador}[3]{%
  331. %~ {\normalfont\bfseries\ttfamily observador\ }%
  332. %~ {\normalfont\ttfamily ##1}%
  333. %~ \ifthenelse{\equal{##2}{}}{}{\ (##2)}\ : ##3%
  334. %~ {\normalfont\bfseries\,;\par}%
  335. %~ }
  336. %~ \newcommand{\observadorconreq}[3]{
  337. %~ & \multicolumn{2}{p{0.85\textwidth}}{\textsf{observador #1}\ensuremath{(#2):#3 \{}}\\
  338. %~ }
  339. %~ \newcommand{\observadorconreqfin}{
  340. %~ & \multicolumn{2}{p{0.85\textwidth}}{\ensuremath{\}}}\\
  341. %~ }
  342. %~ \newcommand{\obsrequiere}[2][]{& & \textsf{requiere #1: }\ensuremath{#2};\\}
  343. %~
  344. %~ \newcommand{\explicacion}[1]{&& #1 \\}
  345. %~ \newcommand{\invariante}[2][]{%
  346. %~ & \multicolumn{2}{p{0.85\textwidth}}{\textsf{invariante #1: }\ensuremath{#2}}\\%
  347. %~ }
  348. %~ \newcommand{\auxinvariante}[2]{
  349. %~ & \multicolumn{2}{p{0.85\textwidth}}{\textsf{aux }\ensuremath{#1 = #2}};\\
  350. %~ }
  351. %~ \newcommand{\auxiliar}[4]{
  352. %~ & \multicolumn{2}{p{0.85\textwidth}}{\textsf{aux }\ensuremath{#1(#2): #3 = #4}};\\
  353. %~ }
  354. \newcommand{\tiponom}[1]{\ensuremath{\mathsf{#1}}\xspace}
  355. \newcommand{\obsnom}[1]{\ensuremath{\mathsf{#1}}}
  356. % -----------------
  357. % Ecuaciones de terminacion en funcional
  358. % -----------------
  359. \newenvironment{ecuaciones}{%
  360. $$
  361. \begin{array}{l @{\ /\ (} l @{,\ } l @{)\ =\ } l}
  362. }{%
  363. \end{array}
  364. $$
  365. }
  366. \newcommand{\ecuacion}[4]{#1 & #2 & #3 & #4\\}
  367. \newcommand{\concat}{\nom{concat}}
  368. % Listas por comprension. El primer parametro es la expresion y el
  369. % segundo tiene los selectores y las condiciones.
  370. %*\newcommand{\comp}[2]{[\,#1\,|\,#2\,]}
  371. % En las practicas/parciales usamos numeros arabigos para los ejercicios.
  372. % Aca cambiamos los enumerate comunes para que usen letras y numeros
  373. % romanos
  374. \newcommand{\arreglarincisos}{%
  375. \renewcommand{\theenumi}{\alph{enumi}}
  376. \renewcommand{\theenumii}{\roman{enumii}}
  377. \renewcommand{\labelenumi}{\theenumi)}
  378. \renewcommand{\labelenumii}{\theenumii)}
  379. }
  380. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARCIAL %%%%%%%%%%%%%%%%%%%%%%%%
  381. \let\@xa\expandafter
  382. \newcommand{\tituloparcial}{\centerline{\depto -- \lamateria}
  383. \centerline{\elnombre -- \lafecha}%
  384. \setlength{\TPHorizModule}{10mm} % Fija las unidades de textpos
  385. \setlength{\TPVertModule}{\TPHorizModule} % Fija las unidades de
  386. % textpos
  387. \arreglarincisos
  388. \newcounter{total}% Este contador va a guardar cuantos incisos hay
  389. % en el parcial. Si un ejercicio no tiene incisos,
  390. % cuenta como un inciso.
  391. \newcounter{contgrilla} % Para hacer ciclos
  392. \newcounter{columnainicial} % Se van a usar para los cline cuando un
  393. \newcounter{columnafinal} % ejercicio tenga incisos.
  394. \newcommand{\primerafila}{}
  395. \newcommand{\segundafila}{}
  396. \newcommand{\rayitas}{} % Esto va a guardar los \cline de los
  397. % ejercicios con incisos, asi queda mas bonito
  398. \newcommand{\anchodegrilla}{20} % Es para textpos
  399. \newcommand{\izquierda}{7} % Estos dos le dicen a textpos donde colocar
  400. \newcommand{\abajo}{2} % la grilla
  401. \newcommand{\anchodecasilla}{0.4cm}
  402. \setcounter{columnainicial}{1}
  403. \setcounter{total}{0}
  404. \newcounter{ejercicio}
  405. \setcounter{ejercicio}{0}
  406. \renewenvironment{ejercicio}[1]
  407. {%
  408. \stepcounter{ejercicio}\textbf{\noindent Ejercicio \theejercicio. [##1
  409. puntos]}% Formato
  410. \renewcommand\@currentlabel{\theejercicio}% Esto es para las
  411. % referencias
  412. \newcommand{\invariante}[2]{%
  413. {\normalfont\bfseries\ttfamily invariante}%
  414. \ ####1\hspace{1em}####2%
  415. }%
  416. \renewcommand{\problema}[5][result]{
  417. \encabezadoDeProblema{####1}{####2}{####3}{####4}\hspace{1em}####5}%
  418. }% Aca se termina el principio del ejercicio
  419. {% Ahora viene el final
  420. % Esto suma la cantidad de incisos o 1 si no hubo ninguno
  421. \ifthenelse{\equal{\value{enumi}}{0}}
  422. {\addtocounter{total}{1}}
  423. {\addtocounter{total}{\value{enumi}}}
  424. \ifthenelse{\equal{\value{ejercicio}}{1}}{}
  425. {
  426. \g@addto@macro\primerafila{&} % Si no estoy en el primer ej.
  427. \g@addto@macro\segundafila{&}
  428. }
  429. \ifthenelse{\equal{\value{enumi}}{0}}
  430. {% No tiene incisos
  431. \g@addto@macro\primerafila{\multicolumn{1}{|c|}}
  432. \bgroup% avoid overwriting somebody else's value of \tmp@a
  433. \protected@edef\tmp@a{\theejercicio}% expand as far as we can
  434. \@xa\g@addto@macro\@xa\primerafila\@xa{\tmp@a}%
  435. \egroup% restore old value of \tmp@a, effect of \g@addto.. is
  436. \stepcounter{columnainicial}
  437. }
  438. {% Tiene incisos
  439. % Primero ponemos el encabezado
  440. \g@addto@macro\primerafila{\multicolumn}% Ahora el numero de items
  441. \bgroup% avoid overwriting somebody else's value of \tmp@a
  442. \protected@edef\tmp@a{\arabic{enumi}}% expand as far as we can
  443. \@xa\g@addto@macro\@xa\primerafila\@xa{\tmp@a}%
  444. \egroup% restore old value of \tmp@a, effect of \g@addto.. is
  445. % global
  446. % Ahora el formato
  447. \g@addto@macro\primerafila{{|c|}}%
  448. % Ahora el numero de ejercicio
  449. \bgroup% avoid overwriting somebody else's value of \tmp@a
  450. \protected@edef\tmp@a{\theejercicio}% expand as far as we can
  451. \@xa\g@addto@macro\@xa\primerafila\@xa{\tmp@a}%
  452. \egroup% restore old value of \tmp@a, effect of \g@addto.. is
  453. % global
  454. % Ahora armamos la segunda fila
  455. \g@addto@macro\segundafila{\multicolumn{1}{|c|}{a}}%
  456. \setcounter{contgrilla}{1}
  457. \whiledo{\value{contgrilla}<\value{enumi}}
  458. {%
  459. \stepcounter{contgrilla}
  460. \g@addto@macro\segundafila{&\multicolumn{1}{|c|}}
  461. \bgroup% avoid overwriting somebody else's value of \tmp@a
  462. \protected@edef\tmp@a{\alph{contgrilla}}% expand as far as we can
  463. \@xa\g@addto@macro\@xa\segundafila\@xa{\tmp@a}%
  464. \egroup% restore old value of \tmp@a, effect of \g@addto.. is
  465. % global
  466. }
  467. % Ahora armo las rayitas
  468. \setcounter{columnafinal}{\value{columnainicial}}
  469. \addtocounter{columnafinal}{-1}
  470. \addtocounter{columnafinal}{\value{enumi}}
  471. \bgroup% avoid overwriting somebody else's value of \tmp@a
  472. \protected@edef\tmp@a{\noexpand\cline{%
  473. \thecolumnainicial-\thecolumnafinal}}%
  474. \@xa\g@addto@macro\@xa\rayitas\@xa{\tmp@a}%
  475. \egroup% restore old value of \tmp@a, effect of \g@addto.. is
  476. \setcounter{columnainicial}{\value{columnafinal}}
  477. \stepcounter{columnainicial}
  478. }
  479. \setcounter{enumi}{0}%
  480. \vspace{0.2cm}%
  481. }%
  482. \newcommand{\tercerafila}{}
  483. \newcommand{\armartercerafila}{
  484. \setcounter{contgrilla}{1}
  485. \whiledo{\value{contgrilla}<\value{total}}
  486. {\stepcounter{contgrilla}\g@addto@macro\tercerafila{&}}
  487. }
  488. \newcommand{\grilla}{%
  489. \g@addto@macro\primerafila{&\textbf{TOTAL}}
  490. \g@addto@macro\segundafila{&}
  491. \g@addto@macro\tercerafila{&}
  492. \armartercerafila
  493. \ifthenelse{\equal{\value{total}}{\value{ejercicio}}}
  494. {% No hubo incisos
  495. \begin{textblock}{\anchodegrilla}(\izquierda,\abajo)
  496. \begin{tabular}{|*{\value{total}}{p{\anchodecasilla}|}c|}
  497. \hline
  498. \primerafila\\
  499. \hline
  500. \tercerafila\\
  501. \tercerafila\\
  502. \hline
  503. \end{tabular}
  504. \end{textblock}
  505. }
  506. {% Hubo incisos
  507. \begin{textblock}{\anchodegrilla}(\izquierda,\abajo)
  508. \begin{tabular}{|*{\value{total}}{p{\anchodecasilla}|}c|}
  509. \hline
  510. \primerafila\\
  511. \rayitas
  512. \segundafila\\
  513. \hline
  514. \tercerafila\\
  515. \tercerafila\\
  516. \hline
  517. \end{tabular}
  518. \end{textblock}
  519. }
  520. }%
  521. \vspace{0.4cm}
  522. \textbf{Nro. de orden:}
  523. \textbf{LU:}
  524. \textbf{Apellidos:}
  525. \textbf{Nombres:}
  526. \vspace{0.5cm}
  527. }
  528. % AMBIENTE CONSIGNAS
  529. % Se usa en el TP para ir agregando las cosas que tienen que resolver
  530. % los alumnos.
  531. % Dentro del ambiente hay que usar \item para cada consigna
  532. \newcounter{consigna}
  533. \setcounter{consigna}{0}
  534. \newenvironment{consignas}{%
  535. \newcommand{\consigna}{\stepcounter{consigna}\textbf{\theconsigna.}}%
  536. \renewcommand{\ejercicio}[1]{\item ##1 }
  537. \renewcommand{\problema}[5][result]{\item
  538. \encabezadoDeProblema{##1}{##2}{##3}{##4}\hspace{1em}##5}%
  539. \newcommand{\invariante}[2]{\item%
  540. {\normalfont\bfseries\ttfamily invariante}%
  541. \ ##1\hspace{1em}##2%
  542. }
  543. \renewcommand{\aux}[4]{\item%
  544. {\normalfont\bfseries\ttfamily aux\ }%
  545. {\normalfont\ttfamily ##1}%
  546. \ifthenelse{\equal{##2}{}}{}{\ (##2)}\ : ##3 \hspace{1em}##4%
  547. }
  548. % Comienza la lista de consignas
  549. \begin{list}{\consigna}{%
  550. \setlength{\itemsep}{0.5em}%
  551. \setlength{\parsep}{0cm}%
  552. }
  553. }%
  554. {\end{list}}
  555. % para decidir si usar && o ^
  556. \newcommand{\y}[0]{\ensuremath{\land}}
  557. % macros de correctitud
  558. \newcommand{\semanticComment}[2]{#1 \ensuremath{#2};}
  559. \newcommand{\namedSemanticComment}[3]{#1 #2: \ensuremath{#3};}
  560. \newcommand{\local}[1]{\semanticComment{local}{#1}}
  561. \newcommand{\vale}[1]{\semanticComment{vale}{#1}}
  562. \newcommand{\valeN}[2]{\namedSemanticComment{vale}{#1}{#2}}
  563. \newcommand{\impl}[1]{\semanticComment{implica}{#1}}
  564. \newcommand{\implN}[2]{\namedSemanticComment{implica}{#1}{#2}}
  565. \newcommand{\estado}[1]{\semanticComment{estado}{#1}}
  566. \newcommand{\invarianteCN}[2]{\namedSemanticComment{invariante}{#1}{#2}}
  567. \newcommand{\invarianteC}[1]{\semanticComment{invariante}{#1}}
  568. \newcommand{\varianteCN}[2]{\namedSemanticComment{variante}{#1}{#2}}
  569. \newcommand{\varianteC}[1]{\semanticComment{variante}{#1}}