Skip to content

Commit

Permalink
lcc.cls: Mejoras varias
Browse files Browse the repository at this point in the history
Opciones de clase
Leyenda configurable
Metadata PDF
  • Loading branch information
mtzguido committed May 12, 2022
1 parent b7e5783 commit 10ba1b0
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.bbl
*.blg
*.log
*.out
*.pdf
287 changes: 189 additions & 98 deletions lcc.cls
Original file line number Diff line number Diff line change
@@ -1,54 +1,92 @@
% Clase LaTeX para LCC
% Por cualquier problema/mejora, ir a
% https://github.com/mtzguido/lcc.cls
\ProvidesClass{lcc}[
2022/4/27 v0.1,
Clase LaTeX para la LCC,
Por cualquier problema/mejora, ir a https://github.com/mtzguido/lcc.cls]

\newif\ifdatos\datosfalse

\def\datosalumno{
\begin{mdframed}[]
Nombre y Apellido:
\end{mdframed}
% Pedir legajo?
}

\def\@tipo{} % Tipo de documento
\def\@tipop{} % Tipo, ``pretty-printed''

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{lcc}[]
\DeclareOption{apunte}{
\def\@tipo{apunte}
\def\@tipop{Apunte}
\date{}
}
\DeclareOption{practica}{
\def\@tipo{practica}
\def\@tipop{Práctica}
\date{}
}
\DeclareOption{tp}{
\def\@tipo{tp}
\def\@tipop{Trabajo Práctico}
\date{}
}
\DeclareOption{parcial}{
\def\@tipo{parcial}
\def\@tipop{Examen Parcial}
\datostrue
}
\DeclareOption{recuperatorio}{
\def\@tipo{recuperatorio}
\def\@tipop{Examen Recuperatorio}
\datostrue
}
\DeclareOption{final}{
\def\@tipo{final}
\def\@tipop{Examen Final}
\datostrue
}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax

\LoadClass[11pt,a4paper]{article}

\RequirePackage[spanish]{babel}
\RequirePackage[utf8]{inputenc}
\RequirePackage[left=2cm,top=3cm,right=1.5cm,bottom=2.5cm]{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{graphicx}
\RequirePackage{color}
\RequirePackage{mdframed}
\RequirePackage{environ}
\RequirePackage{amssymb}
\RequirePackage{enumerate}
\RequirePackage{parskip}
\RequirePackage{hyperref}

% No siempre es necesaria, pero si se requiere tikz,
% hay que usar la librería babel para que ande junto al
% paquete babel. Así que lo agrego para evitar dolores
% de cabeza.
% tikz no es necesario. Pero, si alguien quiere usarlo, necesita agregar
% la % librería babel para que ande junto al paquete babel. Sin ello,
% tenemos un error horrible de compilación. Así que lo agrego para
% evitar potenciales dolores de cabeza.
\RequirePackage{tikz}
\usetikzlibrary{babel}

% Entorno para cosas ocultas.
\NewEnviron{hide}{}{}

\RequirePackage[left=2cm,top=3cm,right=1.5cm,bottom=2.5cm]{geometry}

\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\theenumi}{\bf\alph{enumi}}
\renewcommand{\theenumii}{\roman{enumii}}
\renewcommand{\labelenumi}{\theenumi)}
\renewcommand{\labelenumii}{\theenumii.}

\def\today{\number\day/\number\month/\number\year}
\setlength{\parindent}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0.4pt}
\addtolength{\textheight}{-40pt}
\addtolength{\headheight}{59pt}

\newcounter{problema}

% TODO: Uniformidad. Definir entornos para no usar contador, etc.

\newcounter{problema}

\newenvironment{problema}[1][\unskip]
{\stepcounter{problema}
\textbf{\arabic{problema} #1.~}}
Expand Down Expand Up @@ -88,130 +126,183 @@
\newcommand{\comm}[3]{\ifcomments{{\color{#1}[#2: #3]}}\fi}

% Ejemplo para definir a alguien que comenta.
\newcommand{\guido}[1]{\comm{blue}{Guido}{#1}}
\def\guido{\comm{blue}{Guido}}

% Correr este comando en el .tex para hacer visibles a los entornos solucion
\newcommand{\soluciones}[0]{
\renewenvironment{solucion}
{\solucionOn}
{\endsolucionOn}
\renewenvironment{solucion}
{\solucionOn}
{\endsolucionOn}
}

\def\logofile{}
\newif\iflogo
\logofalse
\newcommand{\logo}[1]{\def\logofile{#1}\logotrue}
% TODO: embeber imagen en este tex, de alguna manera?
\def\@logo{unr.jpg}
\newcommand{\logo}[1]{\def\@logo{#1}}

\newif\ifdatos
\datostrue
\def\datosalumno{Nombre y Apellido:\hspace{200pt}\hrule\medskip}
\def\@codigo{}
\newcommand{\codigo}[1]{\def\@codigo{#1}}

\def\materiastr{}
\newcommand{\materia}[1]{\def\materiastr{#1}}
\def\@materia{\textit{Materia}}
\newcommand{\materia}[1]{\def\@materia{#1}}

\title{}

\newcommand{\parcial}[1]{
\title{Examen Parcial {#1}}
\datostrue
\def\@materiafull{%
\ifx\@codigo\empty
\else
{\@codigo} ---
\fi
{\@materia}
}

\newcommand{\recuperatorio}[1]{
\title{Examen Recuperatorio de Parcial {#1}}
\datostrue
}
\def\@num{}
\newcommand{\num}[1]{\def\@num{#1}}

\newcommand{\final}{
\title{Examen Final}
\datostrue
}
\def\@titulo{}
\newcommand{\titulo}[1]{\def\@titulo{#1}}

\newcommand{\practica}[1]{
\title{Práctica #1}
\date{}
\datosfalse
}
\def\@leyA{Facultad de Ciencias Exactas, Ingeniería y Agrimensura}
\def\@leyB{Escuela de Ciencias Exactas y Naturales}
\def\@leyC{Departamento de Ciencias de la Computación}
\def\@leyD{\@materiafull}
\def\@leyE{}

\newcommand{\trabajopractico}[1]{
\title{Trabajo práctico #1}
\date{}
\datosfalse
\newcommand{\leyenda}[0]{
\begin{tabular}{l}
\ifx\@leyA\empty\else \textsc{\@leyA}\\ \fi
\ifx\@leyB\empty\else \textsc{\@leyB}\\ \fi
\ifx\@leyC\empty\else \textsc{\@leyC}\\ \fi
\ifx\@leyD\empty\else \textsc{\@leyD}\\ \fi
\ifx\@leyE\empty\else \textsc{\@leyE}\\ \fi
\end{tabular}
}

% Si no hay shorttitle, usar title (arreglar: proveer comando para definirlo)
\providecommand{\shorttitle}{\@title}

\newcommand{\leyenda}[0]{
\begin{tabular}{l}
\textsc{Facultad de Ciencias Exactas, Ingeniería y Agrimensura}\\
\textsc{Escuela de Ciencias Exactas y Naturales}\\
\textsc{Departamento de Ciencias de la Computación}\\
\textsc{\materiastr}\\
\end{tabular}
\def\@fancyfooter{
\lfoot{\small \@shorttitle}
\cfoot{\small \@date}
\rfoot{\small Página \thepage}
}

% Estilo primer página, con header
\fancypagestyle{ps_primera}{
\iflogo
\lhead{
\begin{minipage}{3cm}
\includegraphics[width=2.7cm,height=2.7cm]{\logofile}
\end{minipage}
}
\rhead{\leyenda}
\else
\lhead{\leyenda}
\fi

\lfoot{\small \shorttitle}
\cfoot{\small \@date}
\rfoot{\small Página \thepage}
\ifx\@logo\empty
\lhead{\leyenda}
\else
\lhead{
\begin{minipage}{3cm}
\includegraphics[width=2.7cm,height=2.7cm]{\@logo}
\end{minipage}
}
\rhead{\leyenda}
\fi
\@fancyfooter
}

% Estilo de página 2 en adelante.
\fancypagestyle{ps_resto}{
\lhead{\small \materiastr}
\chead{}
\rhead{}
\lhead{\small \@materia}
\chead{}
\rhead{}

\lfoot{\small \shorttitle}
\cfoot{\small \@date}
\rfoot{\small Página \thepage}
\@fancyfooter
}

\def\@fulltitle{%
{\@tipop}
\ifx\@num\empty
\else
{\@num}
\fi
\ifx\@titulo\empty
\else
--
{\@titulo}
\fi
}
\newcommand{\fulltitle}[1]{\def\@fulltitle{#1}}

\def\@fancytitle{
\parskip=1pt

{
\Large\bf
{\@tipop}
\ifx\@num\empty
\else
{\@num}
\fi
}

{\large\sc
\@titulo
}
}
\newcommand{\fancytitle}[1]{\def\@fancytitle{#1}}

\def\@shorttitle{\@fulltitle}
\newcommand{\shorttitle}[1]{\def\@shorttitle{#1}}

\pagestyle{ps_resto}
\def\maketitle{
\thispagestyle{ps_primera}
\ifdatos\datosalumno\fi
\begin{center}
\Large\bf \@title
\end{center}
\thispagestyle{ps_primera}

\ifdatos
\datosalumno
\fi

\begin{center}
\@fancytitle
\end{center}
}

\RequirePackage{listings}
\lstset{
basicstyle=\ttfamily,
keywordstyle=\color{blue},
keepspaces=true,
showstringspaces=false,
columns=flexible,
belowskip=0pt,
basicstyle=\ttfamily,
keywordstyle = \color{blue},
keepspaces=true,
showstringspaces=false,
columns=flexible,
belowskip=0pt,
}

% Código C
\lstdefinestyle{C}{
language=C,
morekeywords=inline,
morekeywords=bool,
language=C,
morekeywords=inline,
morekeywords=bool,
}
\lstnewenvironment{C}[1][]{\lstset{style=C}}{}
\newcommand{\cc}[1]{\lstinline[style=C]`#1`}
\newcommand{\csource}[1]{\lstinputlisting[style=C,basicstyle=\ttfamily\small]{#1}}

% Código Bash
\lstdefinestyle{Bash}{
language=bash,
language=bash,
}
\lstnewenvironment{Bash}[1][]{\lstset{style=bash}}{}
\newcommand{\bash}[1]{\lstinline[style=bash]`#1`}
\newcommand{\bashsource}[1]{\lstinputlisting[style=bash,basicstyle=\ttfamily\small]{#1}}

% Opcional: título y autor para metadata del PDF.
% símbolos especiales que no aparecen.
\def\@pdftitle{}
\newcommand{\pdftitle}[1]{\def\@pdftitle{#1}}
\def\@pdfauthor{}
\newcommand{\pdfauthor}[1]{\def\@pdfauthor{#1}}

\AtBeginDocument{
% Metadata PDF

% Si pdftitle es vacío, usar titulo
\ifx\@pdftitle\empty\def\@pdftitle{\@fulltitle}\fi

% Si pdfauthor es vacío, usar author. Si sigue vacío, usar materia.
% (FIXME: no toma materia, \@author no está vacío?)
\ifx\@pdfauthor\empty\def\@pdfauthor{\@author}\fi
\ifx\@pdfauthor\empty\def\@pdfauthor{\@materia}\fi

\hypersetup{
pdfinfo={
Title={\@pdftitle},
Author={\@pdfauthor},
}
}
}
Loading

0 comments on commit 10ba1b0

Please sign in to comment.