Algo1Macros.tex 20 KB

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