%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pre\'ambulo para compilar junto con config.cfg para Make4ht
% Version 1.0 (Abril, 12, 2026)
% Authors:
% Walter Mora-Flores wmora2@gmail.com (profesor pensionado)
% Instituto Tecnol\'ogico de Costa Rica
% Licencia CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/
% L\'{\i}mite de responsabilidad y exenci\'on de garant\'{\i}a: El autor o los autores han hecho
% su mejor esfuerzo  en la preparaci\'on de este material.
% Esta versi\'on se proporciona “tal cual”.
% Se distribuye  con la esperanza de que sea \'util, pero sin ninguna
% garant\'{\i}a expresa o impl\'{\i}cita respecto a la exactitud o completitud del contenido.
%.:


% =============IMPORTANTE ==============================%%
  \RequirePackage{amsmath}
%=============Esto debe ir aquí para las \int===========%%
%% ----------------------------
%% 1. CONFIGURACI\'oN B\'aSICA DEL DOCUMENTO
%% ----------------------------
\ifdefined\HCode
    \usepackage[spanish,english]{babel} % NO CAMBIAR: make4ht necesita english
    \usepackage[T1]{fontenc}            % Para fuentes con acentos correctamente
    \usepackage[utf8]{inputenc}         % Si usas LaTeX cl\'asico
\else
    \usepackage[utf8]{inputenc}         % Si usas LaTeX cl\'asico
    \usepackage[spanish,english, es-noquoting]{babel}
    \usepackage[autostyle, spanish = mexican]{csquotes} % Manejo de comillas
    \MakeOuterQuote{"}
    \usepackage[T1]{fontenc}            % Para fuentes con acentos
    \usepackage{fancyhdr}
    \usepackage{titlesec}
\fi

%% ----------------------------
%% 2. PAQUETES ESENCIALES
%% ----------------------------
\usepackage{float}                      % Posicionamiento de figuras/tablas
\usepackage{lipsum}                     % Texto de relleno
\usepackage{multicol}                   % M\'ultiples columnas
\usepackage{iftex}                      % Detecci\'on del motor de compilaci\'on
\usepackage[numbers]{natbib}            % Bibliograf\'{\i}a [1],[2]
\usepackage{microtype}                  % Mejoras tipogr\'aficas
\usepackage{xparse}                     % Definici\'on de comandos avanzados
\usepackage{xargs}                      % M\'as opciones para comandos
\usepackage{environ}                    % Entornos personalizados
\usepackage{etoolbox}                   % Herramientas para programaci\'on
\usepackage[table]{xcolor}              % Colores en tablas
\usepackage{colortbl}                   % Colores en tablas (complementario)
\usepackage{cancel}                     % Para tachar t\'erminos matem\'aticos
\usepackage{bbm}                        % S\'{\i}mbolos matem\'aticos especiales
\ifdefined\HCode
\else %solo PDFLatex
\usepackage[counter-format=se.qu,counter-within=section]{exsheets}
\DeclareTranslation{english}{exsheets-exercise-name}{\textcolor{tverde}{Ejercicio}}
 \DeclareTranslation{english}{exsheets-question-name}{\textcolor{tverde}{Pregunta}}
 \DeclareTranslation{english}{exsheets-solution-name}{\textcolor{tverde}{Soluci\'on}}
\SetupExSheets{
	question/pre-body-hook = {\normalfont},
	solution/pre-hook = {\par\medskip},
}
\fi


%% ----------------------------
%% 3. CONFIGURACI\'oN DE TEXTO Y FUENTES
%% ----------------------------
\ifdefined\HCode\else % Fuentes para pdf
\usepackage{pdfpages}
\usepackage{palatino,helvet}            % Fuentes principales
\usepackage{eulervm}                    % Fuente matem\'atica
% ----------------------------
%% DISENO: CABECERAS PDFLATEX -> PDF
%% ----------------------------
\pagestyle{fancy} % Estilo de la p\'agina fancy (usa fancyhdr)
\newcommand{\inforevista}{\protect{\printoffprintinfo}}
\setlength{\headsep}{0.2in} %separaci\'on header con el texto
\newcommand{\helv}{\fontfamily{phv}\fontsize{7.5}{10}\selectfont}
\renewcommand{\sectionmark}[1]{{\markright{#1}{}}}
\fancyhf{} % borra cabecera y pie actuales
\fancyhead[LE,RO]{\bfseries \helv\thepage} %Left Even page - Right Odd page
%\fancyhead[R]{\bfseries \helv\thepage}  % Numeraci\'on siempre a la derecha
\fancyhead[LO]{\helv\rightmark}
\fancyhead[RE]{\helv\leftmark}
\fancyfoot{} % clear all footer fields
%\fancyfoot[L]{{\textcolor{lightgray}{\rule[0.5cm]{0.1\textwidth}{0.1pt}}}\* \\[-0.55cm]\inforevista}
\renewcommand{\headrulewidth}{0pt} % Sin raya. Con raya: cambiar {0} por {0.5pt}
\renewcommand{\footrulewidth}{0pt}
\setlength\headheight{8.5pt}
\fancyheadoffset[R]{0.0cm} %Numeraci\'on de p\'agina en el borde de la p\'agina
\addtolength{\headheight}{0.5pt} % espacio para la raya
\fancypagestyle{plain}{%
\fancyhead{} % elimina cabeceras y raya en p\'aginas "plain"
\renewcommand{\headrulewidth}{0pt} }
% Fin cabeceras ---------------------------------------------

\fi
\usepackage[fixed]{fontawesome5}        % Iconos modernos
\usepackage{latexsym, stmaryrd}         % S\'{\i}mbolos matem\'aticos adicionales
\usepackage{mathtools}                  % Mejoras para matem\'aticas
\usepackage{amssymb, amsthm, amsmath}   % Paquetes AMS est\'andar

%% ----------------------------
%% 4. FORMATO Y DISEÑO
%% ----------------------------
\usepackage[labelfont=bf, font=small]{caption} % Configuraci\'on de caption
\usepackage{subcaption}                 % Subfiguras
\usepackage{enumitem}                   % Personalizaci\'on de listas
\setlist[enumerate]{itemsep=5pt}        % Espaciado en listas

%% ----------------------------
%% 5. ELEMENTOS GR\'aFICOS
%% ----------------------------
\usepackage{tikz}                       % Gr\'aficos vectoriales
\usetikzlibrary{matrix}                 % Funcionalidad adicional para TikZ
\usepackage{adjustbox}                  % Ajuste de cajas
\usepackage{changepage}                 % Ajuste de m\'argenes
\usepackage{array, booktabs}            % Tablas profesionales
\usepackage{multirow}                   % Celdas multi-fila
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} % Columna centrada

%% ----------------------------
%% 6. HIPERV\'{\i}NCULOS Y REFERENCIAS
%% ----------------------------
\usepackage{hyperref}                   % Hiperv\'{\i}nculos
\hypersetup{
    colorlinks=true,
    urlcolor=ligas,
    linkcolor=ligas,
    citecolor=ligas,
    hyperindex=true,
    linktoc=all
}

%% ----------------------------
%% 7. GEOMETR\'{\i}A Y MAQUETACI\'oN
%% ----------------------------
\usepackage[a4paper, top=2cm, bottom=2cm, left=1.5cm, right=1.5cm, headsep=10pt]{geometry}
%% parskip: 12pt en PDF, 0pt en make4ht (el espaciado HTML lo controla el CSS)
\ifdefined\HCode
    \setlength{\parskip}{0pt}
\else
    \setlength{\parskip}{12pt}
\fi

%% ----------------------------
%% 10. DEFINICI\'oN DE COLORES
%% ----------------------------

%% == Paleta principal Legrand-ITCR ==
%%    Ocho colores sem\'anticos para los entornos.
%%    Todos los nombres con sufijo "L" son exclusivos de los entornos.
\definecolor{ocre}{RGB}{243,102,25}       % Naranja Legrand  — teoremas, lemas, ejercicios
\definecolor{azulL}{RGB}{28,108,196}      % Azul             — definiciones, proyectos
\definecolor{verdeL}{RGB}{38,145,65}      % Verde            — ejemplos
\definecolor{grisL}{RGB}{95,95,95}        % Gris             — corolarios, notas, notaciones
\definecolor{moradoL}{RGB}{100,30,155}    % Morado           — axiomas, conjeturas
\definecolor{tealL}{RGB}{0,140,130}       % Verde-azul       — aplicaciones, casos especiales
\definecolor{cafeL}{RGB}{120,75,40}       % Caf\'e             — historia, proyectos
\definecolor{rojoL}{RGB}{190,35,45}       % Rojo             — advertencias
\definecolor{fondoteoremaL}{RGB}{242,242,242}
\definecolor{barraejemploL}{RGB}{39,139,131}

\definecolor{headerblue}{RGB}{0, 82, 147}
\definecolor{rowgray}{RGB}{242, 242, 242}
\definecolor{highlight}{RGB}{255, 215, 0}
%% == Colores funcionales (estructura, comandos, c\'odigo) ==
\definecolor{blanco}{RGB}{255,255,255}
\definecolor{ligas}{RGB}{1,95,173}
\definecolor{rseccion}{rgb}{.0,.0,.3}
\definecolor{fgray}{rgb}{.3,.3,.3}
\definecolor{ffgray}{rgb}{.7,.7,.7}
\definecolor{tverde}{HTML}{176B3B}
\definecolor{torange}{HTML}{993C00}
\definecolor{fntGris}{rgb}{.3,.3,.3}
\definecolor{fntVerde}{RGB}{0,50,0}
%% == Colores para listings ==
\definecolor{mauve}{rgb}{0.58,0,0.82}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.99,0.99,0.99}
\definecolor{lstgray}{RGB}{251,251,251}
%% ----------------------------
%% PORTADA TIPOGR\'aFICA CDI — SOLO PDF
%% Estilo "Printing Poetry" adaptado
%% Uso: \solopdf{\titleCDI}
%% ----------------------------
\ifdefined\HCode\else

\newdimen\drop  % registro de longitud para espaciado vertical

\newcommand*{\titleMG}{%
\begingroup
  \thispagestyle{empty}%
  \drop=0.10\textheight
  %
  \vspace*{\drop}
  %
  %% ── Bloque principal: alineaci\'on derecha (Printing Poetry) ──
  \begin{raggedleft}
    %
    %% Instituci\'on (arriba, pequeño, gris)
    {\fontfamily{phv}\fontsize{10}{12}\selectfont
     \textcolor{grisL}{INSTITUTO TECNOL\'oGICO DE COSTA RICA}%
    }\\[0.4\baselineskip]
    {\fontfamily{phv}\fontsize{10}{8}\selectfont
     \textcolor{grisL}{Escuela de Matem\'atica}%
    }\\[1.8\baselineskip]
    %
    %% Regla decorativa teal
    {\color{tealL}\rule{0.45\textwidth}{1.2pt}}\\[1.4\baselineskip]
    %
    %% T\'{\i}tulo: C\'aLCULO (enorme, palatino)
    {\fontfamily{ppl}\fontseries{b}\fontsize{30}{32}\selectfont
     \textcolor{tealL}{MA0101\;\;\;}%
    }\\[0.6\baselineskip]
    %
    %% Subt\'{\i}tulo: DIFERENCIAL E INTEGRAL
    {\fontfamily{phv}\fontseries{b}\fontsize{62}{64}\selectfont
     \textcolor{black!70}{MATEM\'aTICA GENERAL}%
    }\\[1.2\baselineskip]
    %
    %% Segunda regla (m\'as fina, ocre)
    {\color{ocre}\rule{0.30\textwidth}{0.6pt}}\\[1.5\baselineskip]
    %
    %% Autores
    {\fontfamily{ppl}\fontsize{14}{17}\selectfont
     Reiman Acuña-Chac\'on %
    }\\[0.5\baselineskip]
    {\fontfamily{ppl}\fontsize{14}{17}\selectfont
     Walter Mora-Flores%
    }\\[0.5\baselineskip]
    {\fontfamily{ppl}\fontsize{14}{17}\selectfont
     Melvin Ram\'{\i}rez-Bogantes%
    }\par
    %
  \end{raggedleft}
  %
  \vfill
  %
  %% ── Pie: Revista + año, centrado ──
  \begin{center}
    {\color{ocre}\rule{0.6\textwidth}{0.5pt}}\\[0.8\baselineskip]
    {\fontfamily{phv}\fontsize{10}{8}\selectfont
     \textcolor{grisL}{Revista Matem\'atica Educaci\'on e Internet}\\[0.3\baselineskip]
    \tt{\href{https://tecdigital.tec.ac.cr/servicios/revistamatematica/}{https://tecdigital.tec.ac.cr/servicios/revistamatematica}}%
    }\\[0.9\baselineskip]
    {\fontfamily{ppl}\fontseries{b}\fontsize{18}{20}\selectfont
     \textcolor{ocre}{2026}%
    }%
  \end{center}
  %
  \vspace*{\drop}
\endgroup}

\fi


%% ----------------------------
%% 11. COMANDOS PERSONALIZADOS
%% ----------------------------
\newcommand{\fhvb}[2]{{\fontfamily{phv}\fontseries{b}\fontsize{#1}{1}\selectfont{#2}}}
\newcommand{\fhv}[2]{{\fontfamily{phv}\fontsize{#1}{1}\selectfont{#2}}}
\newcommand{\fvnp}[1]{\fhvb{10}{#1}}
\newcommand{\fvn}[1]{\fhv{10}{#1}}
\newcommand{\fvntt}[1]{\fhv{9.5}{#1}}
\newcommandx{\fntg}[4][1=pag,2=9,3=n]{{\color{fntGris}\fontfamily{#1}\fontsize{#2}{1}\fontshape{#3}\selectfont{#4}}}
\newcommandx{\fnte}[4][1=phv,2=9,3=n]{{\color{fntVerde}\fontfamily{#1}\fontsize{#2}{1}\fontshape{#3}\selectfont{#4}}}
\newcommand{\ofvnp}[1]{\textcolor{torange}{\fvnp{#1}}}
\newcommand{\ofvn}[1]{\textcolor{torange}{\fvnp{#1}}}
\renewcommand{\tt}[1]{\textcolor{tverde}{\fvntt{#1}}}
\newcommand{\wtt}[1]{\textcolor{torange}{\fvntt{#1}}}

%% ----------------------------
%% 12. CONFIGURACI\'oN DE SECCIONES
%% ----------------------------
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesubsection\arabic{subsubsection}}



\newenvironment{ObjetivosEspecificos}{%
{\par\noindent\color{rseccion}\textbf{Objetivos Especificos:}\ \ignorespaces}}

\newenvironment{resumen}{%
{\par\noindent\textcolor{rseccion}{\textbf{Resumen:}}\ \ignorespaces}}


\newenvironment{palabrasclave}{%
{\par\noindent\textcolor{rseccion}{\textbf{Palabras Clave:}}\ \ignorespaces}}


\newenvironment{keywords}{%
{\par\noindent\textcolor{rseccion}{\textbf{Keywords:}}\ \ignorespaces}}




%%-- Titulo del documento-----------------
\makeatletter
\renewcommand{\maketitle}{%
    \begin{flushleft} % Alinea todo a la izquierda
        {\Large\bfseries \@title \par} % T\'{\i}tulo
        \vspace{1em} % Espacio entre t\'{\i}tulo y autores
        {\normalsize \@author \par} % Autores
        \vspace{1em} % Espacio entre autores y fecha
        {\normalsize \@date \par} % Fecha
    \end{flushleft}
    \thispagestyle{empty} % Elimina el n\'umero de p\'agina en la primera p\'agina
}
\makeatother
%%======================================================================
% tcolorbox pdflatex
\usepackage[most]{tcolorbox}
\ifdefined\HCode
  \makeatletter
  %-- Declarar familia /tboxhtml con handler para claves desconocidas
  \pgfkeys{
    /tboxhtml/.is family,
    /tboxhtml,
    title/.initial  = {},
    .unknown/.code  = {},        % descarta colback=, colframe=, etc.
  }
  \renewenvironment{tcolorbox}[1][]{%
    \pgfkeys{/tboxhtml, title={}, #1}%   % #1 = argumento del entorno
    \pgfkeysgetvalue{/tboxhtml/title}{\tbox@stdtitle}%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="tbox-standard">}%
    \ifx\tbox@stdtitle\empty\else
      \HCode{<div class="tbox-standard-title">}%
      \tbox@stdtitle
      \HCode{</div>}%
    \fi
    \par
  }{%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div>}%
    \par
  }
  \makeatother
\fi

%% Definition------
\newtcbtheorem[auto counter]{definition}{D\'efinition}{
                lower separated=false,
                colback=white!80!gray,
colframe=white, fonttitle=\bfseries,
colbacktitle=white!50!gray,
coltitle=black,
enhanced,
boxed title style={colframe=black},
attach boxed title to top left={xshift=0.5cm,yshift=-2mm},
}{def}
\newtcbtheorem[auto counter]{proposition}{Proposition}{%
                lower separated=false,
                colback=white,
colframe=black,fonttitle=\bfseries,
colbacktitle=black,
coltitle=white,
enhanced,
attach boxed title to top left={yshift=-0.1in,xshift=0.15in},
                 boxed title style={boxrule=0pt,colframe=white,},
}{prop}
\newtcbtheorem[auto counter,number within=chapter]{method}{M\'etodo}{%
                lower separated=false,
                colback=white!80!gray,
colframe=white!20!black,fonttitle=\bfseries,
colbacktitle=white!30!gray,
coltitle=black,
enhanced,
attach boxed title to top left={xshift=0.5cm,
        yshift=-2mm},
}{met}

\newtcolorbox{Box4}[2][]{arc=0mm,
                lower separated=false,
                colback=white!30!gray,
colframe=white!20!black,fonttitle=\bfseries,
colbacktitle=white!30!gray,
coltitle=black,
enhanced,
attach boxed title to top left={xshift=0.5cm,
        yshift=-2mm},
title=#2,#1}
%%======================================================================
% Entornos basado en tcolorbox
\usepackage[most]{tcolorbox}
\ifdefined\HCode
  %-- Contadores para los entornos theorem
  \newcounter{definitioncount}
  \newcounter{propositioncount}
  \newcounter{methodcount}[chapter]   % se reinicia en cada cap\'{\i}tulo
  %
  % -------------------------------------------------------
  %  definition  (fondo gris claro, t\'{\i}tulo en caja gris)
  % -------------------------------------------------------
\renewenvironment{definition}[2]{%
  \refstepcounter{definitioncount}%        % ← refstepcounter, no stepcounter
  \ifx\relax#2\relax\else\label{def:#2}\fi % label DESPU\'eS de refstepcounter
  \ifvmode\IgnorePar\fi\EndP
  \HCode{<div class="tbox-definition">}%
  \HCode{<span class="tbox-definition-title">}%
  Definici\'on~\thedefinitioncount%
  \ifx\relax#1\relax\else~(\textit{#1})\fi
  \HCode{</span>}%
  \par
}{%
  \ifvmode\IgnorePar\fi\EndP
  \HCode{</div>}%
  \par
}%

  % -------------------------------------------------------
  %  formula (fondo blanco, marco negro, t\'{\i}tulo negro)
  % -------------------------------------------------------
%\usepackage[many]{tcolorbox}
\tcbuselibrary{skins, breakable, theorems}

\newtcolorbox[auto counter]{formula}{%
  enhanced,
  skin=bicolor,
  before=\centering\bigskip,
  after=\bigskip,
  width=.65\linewidth,
  colback=orange!30,
  fonttitle=\sffamily\bfseries\Large,
  title=F\'ormula~\thetcbcounter,
  arc=15pt,
  colupper=black,
  fontupper=\sffamily\bfseries,
  height=2.5cm,
  valign=center,
  top=-2mm,
  sharp corners,
  sidebyside,
  lower separated=true,
  rounded corners=south,
  attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=-0.25mm-\tcboxedtitleheight/2},
  boxed title style={%
    enhanced,
    colframe=red,
    colback=orange,
    arc=5pt
  },
  frame style={%
    left color=red,
    right color=orange},
  colbacklower=white
}


  % -------------------------------------------------------
  %  proposition  (fondo blanco, marco negro, t\'{\i}tulo negro)
  % -------------------------------------------------------
  \renewenvironment{proposition}[2]{%
    \refstepcounter{propositioncount}%
    \ifx\relax#2\relax\else\label{prop:#2}\fi
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="tbox-proposition">}%
    \HCode{<span class="tbox-proposition-title">}%
    Proposici\'on~\thepropositioncount%
    \ifx\relax#1\relax\else~(\textit{#1})\fi
    \HCode{</span>}%
    \par
  }{%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div>}%
    \par
  }%
  %
  % -------------------------------------------------------
  %  method  (fondo morado suave, n\'umero X.Y)
  % -------------------------------------------------------
  \renewenvironment{method}[2]{%
    \refstepcounter{methodcount}%
    \ifx\relax#2\relax\else\label{met:#2}\fi
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="tbox-method">}%
    \HCode{<span class="tbox-method-title">}%
    M\'etodo~\thechapter.\themethodcount%
    \ifx\relax#1\relax\else~(\textit{#1})\fi
    \HCode{</span>}%
    \par
  }{%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div>}%
    \par
  }%
  %
  % -------------------------------------------------------
  %  Box4  (sin contador, sin label, t\'{\i}tulo como argumento)
  % -------------------------------------------------------
  \renewenvironment{Box4}[2][]{%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="tbox-box4">}%
    \HCode{<span class="tbox-box4-title">}#2\HCode{</span>}%
    \par
  }{%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div>}%
    \par
  }%
\fi
%%========================================================================
%% 8. ENTORNOS PERSONALIZADOS
%%    Diseño inspirado en Legrand Orange Book, implementado con mdframed
%%    Compatible con make4ht (framemethod=default).
%%
%%    Categor\'{\i}as de caja (paralelo con LegrandOrangeBook.cls):
%%      A) tBox  — rect\'angulo completo           → teorema, proposicion
%%      B) dBox  — barra izquierda 4pt, sin bg   → definicion
%%         cBox  — barra izquierda 4pt, bg gris  → corolario
%%         eBox  — barra izquierda 4pt, bg color → actividad, ejercicio
%%      C) ■-box — barra 1pt + s\'{\i}mbolo ■         → ejemplo, notacion
%%      D) barras medias (2–3pt)                  → lema, axiomas, conjetura,
%%                                                   aplicacion, casoespecial,
%%                                                   historia, proyecto, problema
%%      E) C\'{\i}rculo lateral                        → nota, advertencia
%%========================================================================

\usepackage[framemethod=default]{mdframed}

%% Estilo auxiliar sin bordes (para contenido limpio)
\mdfdefinestyle{mdframed-fondoblanco}{
    backgroundcolor=blanco,
    linewidth=0pt,
    topline=false, bottomline=false, rightline=false, leftline=false,
    leftmargin=0pt, rightmargin=0pt,
    innerleftmargin=4pt, innerrightmargin=4pt,
    innertopmargin=6pt, innerbottommargin=0pt,
    skipabove=10pt, skipbelow=10pt,
    linecolor=blanco,
}

%%----------------------------------------------------------------
%%  A) CAJAS RECTANGULARES COMPLETAS  (tBox de Legrand)
%%----------------------------------------------------------------

%% ── Teorema ──────────────────────────────────────────────────
%%    Rect\'angulo naranja, fondo muy tenue.  \'enfasis m\'aximo.
\mdfdefinestyle{mdframed-teorema}{
    backgroundcolor=fondoteoremaL,
    linewidth=0.5pt,   linecolor=ocre,
    topline=true, bottomline=true, rightline=true, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=8pt,  innerbottommargin=8pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{teorema}
\NewDocumentEnvironment{teorema}{o}{%
    \refstepcounter{teorema}%
    \begin{mdframed}[style=mdframed-teorema]%
        \noindent{\color{ocre}\sffamily\bfseries
            Teorema~\theteorema\IfValueT{#1}{~---~#1}.}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Proposici\'on ──────────────────────────────────────────────
%%    Rect\'angulo naranja m\'as delgado.  Resultados de nivel medio.
\mdfdefinestyle{mdframed-proposicion}{
    backgroundcolor=ocre!5!white,
    linewidth=1pt,     linecolor=ocre,
    topline=true, bottomline=true, rightline=true, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=8pt,  innerbottommargin=8pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{proposicion}
\NewDocumentEnvironment{proposicion}{o}{%
    \refstepcounter{proposicion}%
    \begin{mdframed}[style=mdframed-proposicion]%
        \noindent{\color{ocre}\sffamily\bfseries
            Proposici\'on~\theproposicion\IfValueT{#1}{~(#1)}.}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%%----------------------------------------------------------------
%%  B-1) BARRA IZQUIERDA 4pt SIN FONDO  (dBox de Legrand)
%%----------------------------------------------------------------

%% ── Definici\'on ───────────────────────────────────────────────
%%    Barra azul 4pt, fondo blanco.  Conceptos fundamentales.
\mdfdefinestyle{mdframed-definicion}{
    backgroundcolor=blanco,
    linewidth=4pt,     linecolor=azulL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=6pt,  innerbottommargin=6pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{definicion}
\NewDocumentEnvironment{definicion}{o}{%
    \refstepcounter{definicion}%
    \begin{mdframed}[style=mdframed-definicion]%
        \noindent{\color{azulL}\sffamily\bfseries
            Definici\'on~\thedefinicion\IfValueT{#1}{~(#1)}.}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%%----------------------------------------------------------------
%%  B-2) BARRA IZQUIERDA 4pt CON FONDO GRIS  (cBox de Legrand)
%%----------------------------------------------------------------

%% ── Corolario ────────────────────────────────────────────────
%%    Barra gris 4pt, fondo gris muy tenue.  Consecuencias.
\mdfdefinestyle{mdframed-corolario}{
    backgroundcolor=black!4,
    linewidth=4pt,     linecolor=grisL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{corolario}
\NewDocumentEnvironment{corolario}{o}{%
    \refstepcounter{corolario}%
    \begin{mdframed}[style=mdframed-corolario]%
        \noindent{\color{grisL}\sffamily\bfseries
            Corolario~\thecorolario\IfValueT{#1}{~(#1)}.}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%%----------------------------------------------------------------
%%  C) BARRA 1pt + S\'{\i}MBOLO ■  (blacknumex de Legrand)
%%----------------------------------------------------------------

%% ── Ejemplo ──────────────────────────────────────────────────
%%    ■ al inicio y al final.  Barra verde delgada, fondo muy tenue.
\mdfdefinestyle{mdframed-ejemplo}{
    backgroundcolor=verdeL!5!white,
    linewidth=4pt,     linecolor=barraejemploL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=6pt,  innerbottommargin=6pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{ejemplo}
\NewDocumentEnvironment{ejemplo}{o}{%
    \refstepcounter{ejemplo}%
    \begin{mdframed}[style=mdframed-ejemplo]%
        \noindent{%
            \raisebox{1.25pt}{\tiny\ensuremath{\blacksquare}}~%
            {\color{black!75}\sffamily\bfseries
             Ejemplo~\theejemplo\IfValueT{#1}{~---~#1}.}}%
        \par\noindent\ignorespaces
    }{%
        %\hfill{\color{verdeL!80!black}\tiny\ensuremath{\blacksquare}}%
    \end{mdframed}%
}

%% ── Notaci\'on ─────────────────────────────────────────────────
%%    ■ al inicio.  Barra gris 1.5pt, fondo gris muy sutil.  (nuevo)
\mdfdefinestyle{mdframed-notacion}{
    backgroundcolor=black!3,
    linewidth=1.5pt,   linecolor=grisL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=6pt,  innerbottommargin=6pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{notacion}
\NewDocumentEnvironment{notacion}{o}{%
    \refstepcounter{notacion}%
    \begin{mdframed}[style=mdframed-notacion]%
        \noindent{%
            \raisebox{1.25pt}{\tiny\ensuremath{\blacksquare}}~%
            {\color{grisL}\sffamily\bfseries
             Notaci\'on~\thenotacion\IfValueT{#1}{~---~#1}.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%%----------------------------------------------------------------
%%  D) BARRAS MEDIAS 2–3pt  (entornos secundarios)
%%----------------------------------------------------------------

%% ── Lema ─────────────────────────────────────────────────────
%%    Barra naranja 3pt, fondo ocre muy tenue.
\mdfdefinestyle{mdframed-lema}{
    backgroundcolor=ocre!5!white,
    linewidth=3pt,     linecolor=ocre!80!black,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\newcounter{lemap}
\NewDocumentEnvironment{lema}{o}{%
    \refstepcounter{lemap}%
    \begin{mdframed}[style=mdframed-lema]%
        \noindent{\color{ocre!80!black}\sffamily\bfseries
            Lema~\thelemap\IfValueT{#1}{~(#1)}.}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Axiomas ──────────────────────────────────────────────────
%%    Barra morada 2pt, fondo morado muy tenue.
\mdfdefinestyle{mdframed-axiomas}{
    backgroundcolor=moradoL!4!white,
    linewidth=2pt,     linecolor=moradoL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{axiomas}{o}{%
    \begin{mdframed}[style=mdframed-axiomas]%
        \noindent{\color{moradoL}\sffamily\bfseries
            \IfValueT{#1}{#1.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Conjetura ────────────────────────────────────────────────
%%    Barra morada 2pt algo m\'as clara, fondo muy tenue.
\mdfdefinestyle{mdframed-principio}{
    backgroundcolor=moradoL!3!white,
    linewidth=2pt,     linecolor=moradoL!70!black,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{principio}{o}{%
    \begin{mdframed}[style=mdframed-principio]%
        \noindent{\color{moradoL!80!black}\sffamily\bfseries
            \IfValueT{#1}{#1.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Aplicaci\'on ───────────────────────────────────────────────
%%    Barra teal 2pt, fondo teal muy tenue.
\mdfdefinestyle{mdframed-aplicacion}{
    backgroundcolor=tealL!5!white,
    linewidth=2pt,     linecolor=tealL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{aplicacion}{o}{%
    \begin{mdframed}[style=mdframed-aplicacion]%
        \noindent{\color{tealL}\sffamily\bfseries
            Aplicaci\'on\IfValueT{#1}{:~#1}.}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Caso especial ────────────────────────────────────────────
%%    Barra teal 1.5pt, fondo teal a\'un m\'as tenue.
\mdfdefinestyle{mdframed-casoespecial}{
    backgroundcolor=tealL!4!white,
    linewidth=1.5pt,   linecolor=tealL!70!black,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{casoespecial}{o}{%
    \begin{mdframed}[style=mdframed-casoespecial]%
        \noindent{\color{tealL!80!black}\sffamily\bfseries
            \IfValueT{#1}{#1.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Historia ─────────────────────────────────────────────────
%%    Barra caf\'e 2pt, fondo caf\'e muy tenue.
\mdfdefinestyle{mdframed-historia}{
    backgroundcolor=cafeL!5!white,
    linewidth=2pt,     linecolor=cafeL,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{historia}{o}{%
    \begin{mdframed}[style=mdframed-historia]%
        \noindent{\color{cafeL}\sffamily\bfseries
            \IfValueT{#1}{#1.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Proyecto ─────────────────────────────────────────────────
%%    Barra azul 2pt, fondo azul muy tenue.
\mdfdefinestyle{mdframed-proyecto}{
    backgroundcolor=azulL!4!white,
    linewidth=2pt,     linecolor=azulL!60!black,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{proyecto}{o}{%
    \begin{mdframed}[style=mdframed-proyecto]%
        \noindent{\color{azulL!80!black}\sffamily\bfseries
            \IfValueT{#1}{#1.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Problema ─────────────────────────────────────────────────
%%    Barra naranja 2pt, fondo ocre muy tenue.
\mdfdefinestyle{mdframed-problema}{
    backgroundcolor=ocre!5!white,
    linewidth=2pt,     linecolor=ocre!70!black,
    topline=false, bottomline=false, rightline=false, leftline=true,
    leftmargin=0pt,    rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=7pt,  innerbottommargin=7pt,
    skipabove=10pt,    skipbelow=10pt,
}
\NewDocumentEnvironment{problema}{o}{%
    \begin{mdframed}[style=mdframed-problema]%
        \noindent{\color{ocre!80!black}\sffamily\bfseries
            \IfValueT{#1}{#1.}}%
        \par\noindent\ignorespaces
    }{%
    \end{mdframed}%
}

%% ── Caja gen\'erica ────────────────────────────────────────────
%%    Barra gris 1pt. Uso libre con argumento opcional como t\'{\i}tulo.
\NewDocumentEnvironment{caja}{o}{%
    \begin{mdframed}[
        backgroundcolor=white,
        linewidth=1pt,     linecolor=grisL!50,
        topline=false, bottomline=false, rightline=false, leftline=true,
        leftmargin=0pt,    rightmargin=0pt,
        innerleftmargin=8pt, innerrightmargin=8pt,
        innertopmargin=5pt,  innerbottommargin=5pt,
        skipabove=5pt,     skipbelow=5pt,
    ]%
    \noindent{\color{grisL}\sffamily\bfseries\IfValueT{#1}{#1.}}%
    \ignorespaces\;%
}{%
    \end{mdframed}%
}

%%----------------------------------------------------------------
%%  B-3) BARRA 4pt + FONDO COLOR  (eBox de Legrand)  — Actividad
%%----------------------------------------------------------------

%% ── Actividad interactiva ────────────────────────────────────
%%    Barra naranja 4pt, fondo ocre!10.  Id\'entico al eBox de Legrand.
\newmdenv[
    backgroundcolor=ocre!10!white,
    leftmargin=0pt,      rightmargin=0pt,
    innerleftmargin=8pt, innerrightmargin=8pt,
    innertopmargin=8pt,  innerbottommargin=8pt,
    skipabove=10pt,      skipbelow=10pt,
    linecolor=ocre,
    topline=false, bottomline=false, rightline=false, leftline=true,
    linewidth=4pt,
    nobreak=true,
    frametitle={\textbf{\color{ocre}\sffamily\faBolt\;Actividad Interactiva}}
]{hactividad}
\NewDocumentEnvironment{actividad}{O{}}
{\begin{hactividad}\noindent #1}
{\end{hactividad}}

%%----------------------------------------------------------------
%%  E) C\'{\i}RCULO LATERAL  (remark de Legrand)
%%----------------------------------------------------------------

%% ── Nota ─────────────────────────────────────────────────────
%%    C\'{\i}rculo "N" gris a la izquierda, texto en bloque indentado.
\newenvironment{nota}{%
    \par\small
    \vspace{2pt}
    \begin{adjustwidth}{35pt}{25pt}
        \hspace{-1.5pt}%
        \begin{tikzpicture}[overlay]
            \node[draw=grisL, line width=1pt, circle,
                  fill=grisL!20, font=\sffamily\bfseries,
                  inner sep=3pt, outer sep=0pt]
                  at (-15pt,5pt){\textcolor{grisL}{N}};
        \end{tikzpicture}
        \advance\baselineskip -1pt%
    }{%
    \end{adjustwidth}
}

%% ── Advertencia ──────────────────────────────────────────────
%%    C\'{\i}rculo "!" rojo a la izquierda.  Para avisos importantes.  (nuevo)
\newenvironment{advertencia}{%
    \par\small
    \vspace{2pt}
    \begin{adjustwidth}{35pt}{25pt}
        \hspace{-1.5pt}%
        \begin{tikzpicture}[overlay]
            \node[draw=rojoL, line width=1pt, circle,
                  fill=rojoL!15, font=\sffamily\bfseries,
                  inner sep=3pt, outer sep=0pt]
                  at (-15pt,5pt){\textcolor{rojoL}{!}};
        \end{tikzpicture}
        \advance\baselineskip -1pt%
    }{%
    \end{adjustwidth}
}

%%========================================================================


%% ----------------------------
%% 14. LISTADOS DE C\'oDIGO
%% ----------------------------
\RequirePackage{listings}
\lstset{captionpos=t}
\renewcommand{\lstlistingname}{C\'odigo} % Es importante el acento de esa manera

\captionsetup[lstlisting]{%
    labelfont=bf,
}
\lstset{
	language={[latex]TeX}, % Lenguaje LaTeX
	backgroundcolor=\color{backcolour}, % Color de fondo
	basicstyle=\small\fontseries{b}\ttfamily, % Estilo b\'asico
	breakatwhitespace=false, % No romper l\'{\i}neas en espacios en blanco
	breaklines=true, % Romper l\'{\i}neas largas
	commentstyle=\color{mauve}, % Estilo de los comentarios
	escapeinside={\%*}{*)}, % Escapar dentro del c\'odigo
	extendedchars=true, % Caracteres extendidos
	frame=single, % Marco alrededor del c\'odigo
	keepspaces=true, % Mantener espacios
	moredelim=[is][\color{red}]{\%*}{*\%}, % Delimitador personalizado
	keywordstyle=\color{blue}, % Estilo de las palabras clave
	morekeywords={*,usepackage,begin,end, lstinline, newenvironment,
		tabular, minipage, pmatrix,bmatrix, includegraphics,captionof,width,scale,rowcolor,multirow,multicolumn, documentclass, input,ifdefined, HCode,Configure,fi, ConfigureEnv,insertarhtml, ifvmode,label,Css,pdfomk,ejersol,hejersol, solomk, solopdf, cejillamk,dosventanasmk,botonvertutor,ifventana,ancla,ifventanapdf,linea,tablahoverfilas},
	texcsstyle=[1]\color{blue},%label, caption, etc.
	numbers=none,
	rulecolor=\color{gray}, % Color de la regla
	showspaces=false,
	showstringspaces=false,
	showtabs=false,
	stringstyle=\color{mauve}, % Estilo de las cadenas
	literate= {∩}{{$\cap$}}1 {á}{{\'a}}1 {é}{{\'e}}1 {í}{{{\'\i}}}1 {ó}{{\'o}}1 {ö}{{\"o}}1 {ő}{{\H o}}1 {\'u}{{\'u}}1 {ú}{{\'U}}1 {ü}{{\"u}}1 {ű}{{\H u}}1 {Ü}{{\"U}}1
}

%%--Comandos
\newcommand\smallmath[1]{\begingroup\footnotesize #1\endgroup}

%% logo-link  para  imagen  para saltar a una actividad interactiva en el html
\newcommand{\wref}[2]{%
	\begin{tikzpicture}
		\node[inner sep=0pt] (img) at (0,0) {#2}; % \includegraphics{}
		\node[anchor=north east, scale=0.7, xshift=-5pt, yshift=5pt] at (img.north east)
		{\href{#1}{%
				\textcolor{blue}{
					\begin{tabular}{r@{}p{5pt}} % @{} elimina espacio entre columnas
						{\Large\faLink} & \begin{tabular}{@{}l@{}} % @{} ajusta la segunda columna
							\textbf{Ir al} \\[-2.5pt] % Ajuste fino de separaci\'on vertical
							\textbf{HTML}
						\end{tabular}
					\end{tabular}
				}
		}};
	\end{tikzpicture}
}

%%──────────────────────────────────────────────────────────────────────
%% tablaverdad — Tabla de verdad con diseño del libro
%%   #1 = especificaci\'on interna de columnas (sin bordes externos)
%%        Ejemplo: cc|c|c|c
%%
%% Comandos auxiliares:
%%   \tvh{expr}  — celda de encabezado (blanca en PDF, clase css en HTML)
%%   \tvhline    — l\'{\i}nea separadora bajo el encabezado
%%   \tvV / \tvF — valores con color (verde / rojo)
%%
%% Requiere: booktabs, colortbl, xcolor  (ya en pre\'ambulo)
%%──────────────────────────────────────────────────────────────────────

%% ── \tvV y \tvF ─────────────────────────────────────────────
\ifdefined\HCode
  \newcommand{\tvV}{\HCode{<span class="tv-V">}V\HCode{</span>}}
  \newcommand{\tvF}{\HCode{<span class="tv-F">}F\HCode{</span>}}
\else
  \newcommand{\tvV}{\textbf{\textcolor{verdeL}{V}}}
  \newcommand{\tvF}{\textbf{\textcolor{rojoL}{F}}}
\fi

%% ── \tvheaderrow  (mismo patr\'on que \rowgris) ───────────────
\ifdefined\HCode
  \newcommand{\tvheaderrow}{}%      make4ht ya emiti\'o el <tr>, no se puede reemplazar
\else
  \newcommand{\tvheaderrow}{\rowcolor{tealL}}
\fi
%% ── \tvhline  — separador post-encabezado ───────────────────
\ifdefined\HCode
  \newcommand{\tvhline}{}   % CSS lo maneja
\else
  \newcommand{\tvhline}{%
    \arrayrulecolor{tealL}\hline\arrayrulecolor{tealL!35}%
  }
\fi

%% ── \tvh{} — celda de encabezado ────────────────────────────
\newcommand{\tvh}[1]{%
  \ifdefined\HCode
    #1%
  \else
    \textcolor{white}{\bfseries\small #1}%
  \fi
}

%% ── entorno tablaverdad ─────────────────────────────────────
\newenvironment{tablaverdad}[1]{%
  %% — HTML —
  \ifdefined\HCode
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="tabla-hover-filas tablaverdad">^^J}%
    \par
    \begin{center}%
    \small
    \begin{tabular}{#1}%
  %% — PDF —
  \else
    \begin{center}%
    \begingroup
    \small
    \renewcommand{\arraystretch}{1.40}%
    \arrayrulecolor{tealL!35}%
    \setlength{\arrayrulewidth}{0.5pt}%
    \begin{tabular}{!{\color{tealL}\vrule width 1pt}#1!{\color{tealL}\vrule width 1pt}}%
    \arrayrulecolor{tealL}\specialrule{1pt}{0pt}{0pt}%
    \arrayrulecolor{tealL!35}%
  \fi
}{%
  \ifdefined\HCode
    \end{tabular}%
    \end{center}%
    \par
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div>^^J}%
    \par
  \else
    \arrayrulecolor{tealL}\specialrule{1pt}{0pt}{0pt}%
    \end{tabular}%
    \endgroup
    \end{center}%
  \fi
}

%% ─────────────────────────────────────────────────────────────
%% objetivoscap — Caja de Objetivos Espec\'{\i}ficos del cap\'{\i}tulo
%% Requiere: booktabs, xcolor, colortbl  (ya en pre\'ambulo)
%%
%% Uso en el documento:
%%   \begin{objetivoscap}              % t\'{\i}tulo por defecto
%%   \begin{objetivoscap}[Otro t\'{\i}tulo] % t\'{\i}tulo personalizado
%%     \textit{Intro...} \\[4pt]
%%     \quad 1.1) item \\
%%     \quad 1.6) item \\[2pt]    ← \'ultimo \'{\i}tem termina con \\
%%   \end{objetivoscap}
%%
%% Compatible: pdflatex y make4ht
%% ─────────────────────────────────────────────────────────────
\newenvironment{objetivoscap}[1][Objetivos Espec\'{\i}ficos]{%
  %% ── HTML (make4ht) ─────────────────────────────────────────
  \ifdefined\HCode
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="obj-box">^^J}%
    \HCode{<div class="obj-header">#1</div>^^J}%
    \HCode{<div class="obj-body">^^J}%
    \par\noindent\sffamily\small
  %% ── PDF (pdflatex) ─────────────────────────────────────────
  \else
    \begin{quote}%
    \begingroup
      \sffamily\small
      \arrayrulecolor{tealL}%
      \renewcommand{\arraystretch}{1.45}%
      \rowcolors{2}{tealL!7}{tealL!7}%
      \begin{tabular}{%
        !{\color{tealL}\vrule width 4pt}%          barra izq. teal
         p{\dimexpr\linewidth - 4pt\relax}}%
        \specialrule{1.5pt}{0pt}{0pt}%             regla superior gruesa
        \rowcolor{tealL}%
        \multicolumn{1}{!{\color{tealL}\vrule width 4pt}c}{%
          \rule{0pt}{13pt}%                         padding superior
          \textcolor{white}{\bfseries #1}%
          \rule[-3pt]{0pt}{3pt}%                    padding inferior
        }\\%
  \fi
}{%
  \ifdefined\HCode
    \par
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div>^^J</div>^^J}%
    \par
  \else
        \specialrule{1.5pt}{0pt}{0pt}%             regla inferior gruesa
      \end{tabular}%
    \endgroup%
    \end{quote}%
  \fi
}


%% ----------------------------
%% 9. CONFIGURACI\'oN PARA MAK4HT
%% ----------------------------

%
%1.) Tablas hover...PDFLatex ignora,
%    Make4ht lo aplica:Una envoltura <div class="tabla-hover-filas">...
\newenvironment{tablahoverfilas}
  {%
    \ifdefined\HCode
      \ifvmode\IgnorePar\fi\EndP
      \HCode{<div class="tabla-hover-filas">}%
      \par
    \fi
  }
  {%
    \ifdefined\HCode
      \ifvmode\IgnorePar\fi\EndP
      \HCode{</div>}%
      \par
    \fi
  }
%
% \rowcolor{rowgray} tapa el hover, \rowgris para css y da \rowcolor{rowgray} para pdf
\ifdefined\HCode
  \newcommand{\rowgris}{\HCode{<tr class="rowgray">}}
\else
  \newcommand{\rowgris}{\rowcolor{rowgray}}
\fi
%%--
%2.) \vspace \bigskip, \medskip, \smallskip para html
\newcommand{\linea}{\textcolor{lightgray}{\rule{\linewidth}{0.4pt}}\par}
\ifdefined\HCode
  \def\bigskip{\HCode{<div style="margin-top:2em;"></div>}}
  \def\medskip{\HCode{<div style="margin-top:1.5em;"></div>}}
  \def\smallskip{\HCode{<div style="margin-top:1em;"></div>}}
  \def\linea{\HCode{<hr style="height:1px; border:none; background-color:\#ccc; margin:20px 0;">}}
\fi
%
\ifdefined\HCode
  \newcommand{\vspacemk}[1]{\HCode{<div style="margin-top:#1;"></div>}}
\else
  \newcommand{\vspacemk}[1]{\vspace*{#1}}
\fi
\ifdefined\HCode
  \newcommand{\hspacemk}[1]{\HCode{<span style="display:inline-block; width:#1;"></span>}}
\else
  \newcommand{\hspacemk}[1]{\hspace*{#1}}
\fi
%% \vspacehtml{1em}
%%--
% 3.) Comandos \pdfomk{#1}{#2} e \insertarhtml{}
% 3a.) \pdfomk{#1}{#2}
\ifdefined\HCode
\long\def\solopdf#1{\protect}  % ignorado por make4ht
\long\def\solomk#1{\protect#1} % procesado en make4ht
\else
\long\def\solopdf#1{\protect#1} % procesado en PDF
\long\def\solomk#1{\protect}    % ignorado por PDF
\fi
%
\ifdefined\HCode
\long\def\pdfomk#1#2{%
	\protect#2%html
}
\else
\long\def\pdfomk#1#2{%
	\protect#1%pdf
}
\fi
%-3b.)--Insertar html

%
%--\insertarhtml{#1} %Para html PURO
  \ifdefined\HCode
    \long\def\insertarhtml#1{%
      \HCode{#1}%
    }
  \else
    \long\def\insertarhtml#1{%
      %nada%\textbf{[Contenido interactivo no disponible en PDF]}
    }
  \fi
%
%- 4.) Un entorno para ejercicio con bot\'on para ver/ocultar respuesta
%
\newcounter{htmlEjercicio}[section]
\renewcommand{\thehtmlEjercicio}{%
  \ifnum\value{section}=0
    \arabic{htmlEjercicio}%
  \else
    \thesection\arabic{htmlEjercicio}%
  \fi
}
% Nota: Debemos poner \insertarhtml{<script src="js/ejerciciosolucion.js" defer></script>}
% antes de \end{document}
\newcommand{\hejersol}[2]{%
    \stepcounter{htmlEjercicio}%
    \par\medskip
        \ifvmode\IgnorePar\fi\EndP
    \noindent\textbf{Ejercicio \thehtmlEjercicio.}
    #1%
        \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="ejercicio-solucion">}%
    \HCode{<div class="solucion-container">}%
 \HCode{<button onclick="toggleSolucion(this)">Solucion</button>}%%%
    \HCode{<div class="solucion"><div class="solucion-inner">}%
        \ifvmode\IgnorePar\fi\EndP
    #2%
        \ifvmode\IgnorePar\fi\EndP
    \HCode{</div></div></div></div>}%
    \par\medskip
}
\newcommand{\snhejersol}[2]{% Sin Numeración, \itemps
    \par\medskip
    \ifvmode\IgnorePar\fi\EndP
    #1%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="ejercicio-solucion">}%
    \HCode{<div class="solucion-container">}%
    \HCode{<button onclick="toggleSolucion(this)">Solucion</button>}%%%
    \HCode{<div class="solucion"><div class="solucion-inner">}%
    \ifvmode\IgnorePar\fi\EndP
    #2%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{</div></div></div></div>}%
    \par\medskip
}

\newcommand{\listahejersol}[1]{% Sin solución pero numeración si, para una lista
    \stepcounter{htmlEjercicio}%
    \par\medskip
    \ifvmode\IgnorePar\fi\EndP
    \noindent\textbf{Ejercicio \thehtmlEjercicio.}
    #1%
    \ifvmode\IgnorePar\fi\EndP
    \par\medskip
}
\newcommand{\listaejer}[1]{%
    \begin{question}%
        #1%
    \end{question}%
}
\ifdefined\HCode
    \renewcommand{\listaejer}[1]{\listahejersol{#1}}
\fi

\newcommand{\bex}{\begin{enumerate}}
\newcommand{\eex}{\end{enumerate}}
%-------------------listas de ejercicios SIN jerciciosx.y
\ifx\HCode\undefined
  \newcommand{\itemps}[2]{\item #1\scantokens{\begin{solution}#2\end{solution}}}
\else
  \newcommand{\itemps}[2]{\item \snhejersol{#1}{#2}}
\fi
%%-- pdf-exsheet y make4ht Numeración

% Sobrescribir para make4ht (HTML)
\ifx\HCode\undefined
  \newcommand{\ejersol}[2]{\begin{question}#1\end{question}\begin{solution}#2\end{solution}}
\else
  \newcommand{\ejersol}[2]{\hejersol{#1}{#2}}
\fi
%
% 5.) Cejilla make4ht y pdf

\newcount\cejillaCounter
\cejillaCounter=0
\long\def\cejillamk#1#2{%
    \ifx\HCode\undefined
        % ═══ MODO PDF: Solo contenido ═══
        #2%
    \else
        % ═══ MODO HTML: Cejilla completa ═══
        \global\advance\cejillaCounter by 1
        \edef\cejillaId{cejilla-\number\cejillaCounter}%
        \ifvmode\IgnorePar\fi\EndP
        \HCode{<div class="cejilla-wrapper" style="margin: 1rem 0;">}%
      \HCode{<button class="cejilla-toggle"
        aria-expanded="false"
        aria-controls="\cejillaId">}%
\HCode{<span class="cejilla-icon">▶</span>}%
\HCode{<span class="cejilla-label">}%
#1%
\HCode{</span>}%
\HCode{</button>}%
        \HCode{<div class="cejilla-content" id="\cejillaId" hidden="true">}%
        \ifvmode\IgnorePar\fi\EndP
        #2%
        \ifvmode\IgnorePar\fi\EndP
        \HCode{</div>}%
        \HCode{</div>}%
        \par\medskip
    \fi
}
 % 6. ancla
 % Ancla HTML (solo make4ht, invisible en PDF)  \ancla{ej-limites-1}
\ifdefined\HCode
  \newcommand{\ancla}[1]{%
    \HCode{<a id="}%
    \detokenize{#1}%
    \HCode{"></a>}%
  }%
\else
  \newcommand{\ancla}[1]{}%
\fi
%========================================
%% ----------------------------
%%  Ejemplo:
%%    \dosventanasmk{js/clt.html}{800}{500}{80}{70}
%%      {Simulaci\'on CLT}{Requiere conexi\'on a internet.}
%% ----------------------------
%% \dosventanasmk — diseño de colores coherente con \cejillamk
\ifdefined\HCode
  \newcounter{dvcount}
  \NewDocumentCommand{\dosventanasmk}{m m m m m m m}{%
    \stepcounter{dvcount}%
    \edef\dvid{dv\arabic{dvcount}}%
    \ifvmode\IgnorePar\fi\EndP
    \HCode{<div class="iframe-container">}%
    \HCode{<div class="iframe-descripcion" id="desc-\dvid">}#6\HCode{</div>}%
    \HCode{<div id="w\dvid" style="width:#2px; height:#3px; overflow:hidden; position:relative;">}%
    \HCode{<iframe id="\dvid" src="}\detokenize{#1}%
    \HCode{" frameborder="0" width="#2" height="#3"}%
    \HCode{ style="border:1px solid \#c8c8c8; border-left:3px solid \#b0b0b0; background:\#f2f2f2; display:block; transform-origin:top left;"}%
    \HCode{ title="Contenido incrustado"></iframe>}%
    \HCode{</div>}%
    \HCode{<script>(function(){var ifrm=document.getElementById('\dvid');var wrap=document.getElementById('w\dvid');var nW=#2,nH=#3,lastW=0;ifrm.style.width=nW+'px';ifrm.style.height=nH+'px';function fit(){var cW=wrap.offsetWidth;if(cW===0||cW===lastW)return;lastW=cW;var sc=cW/nW;ifrm.style.transform='scale('+sc+')';ifrm.style.transformOrigin='top left';wrap.style.height=Math.round(nH*sc)+'px';}fit();window.addEventListener('resize',fit);new ResizeObserver(function(){fit();}).observe(wrap);})()</script>}%
    \HCode{<button class="btn-ventanaVV"}%
    \HCode{ onclick="AbrirVentana(document.getElementById('\dvid').getAttribute('src'),document.getElementById('desc-\dvid').textContent,}#4\HCode{,}#5\HCode{)">}%
    \HCode{<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor">}%
    \HCode{<rect x="1" y="4" width="10" height="10" rx="1.5" stroke-width="1.5"/>}%
    \HCode{<path d="M7 1H15V9" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>}%
    \HCode{<path d="M9 7L15 1" stroke-width="1.5" stroke-linecap="round"/>}%
    \HCode{</svg> Abrir en ventana independiente</button>}%
    \HCode{<span class="iframe-hint">}#7\HCode{</span>}%
    \HCode{</div>}%
    \par
  }%
\else
  \NewDocumentCommand{\dosventanasmk}{m m m m m m m}{}%
\fi
%%--------------------------------------------------------------------%%
\ifdefined\HCode
  % make4ht: preferir PNG
  \DeclareGraphicsExtensions{.png,.jpg,.jpeg,.pdf}
\else
  % pdflatex: preferir PDF (mejor calidad vectorial)
  \DeclareGraphicsExtensions{.pdf,.png,.jpg,.jpeg}
\fi

%----Emular la listas viejas de ejercicios

