3

I am working on a book which each chapter has an image .jpg or .png. The code that accomplishes this is:

\newcommand{\thechapterimage}{}
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}
\def\thechapter{\arabic{chapter}}
\def\@makechapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]

\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};

%Comentando las 3 líneas de abajo quita la caja de contenidos en el título del capítulo
\draw[rounded corners=10pt, fill=white,opacity=0.5] (1cm,0cm) rectangle (8cm,-9.3cm);                   %%%%%%%%%%%%%%%%%%% minitabla
\node[anchor=north west] at (1cm,.25cm) {\parbox[t][8cm][t]{6.5cm}{\huge\bfseries\flushleft \printcontents{l}{1}{\setcounter{tocdepth}{2}}}};

\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,fill=white,fill opacity=.6,text opacity=1,draw=colordominante,draw opacity=1,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{\thechapter\ ---\ #1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}

In the main document, you would call the name of a figure just before the chapter command:

\chapterimage{imagen4.png} 
\chapter{Estadística y probabilidad}

Whose generated image is

enter image description here

The question is whether it is possible to modify the previous code where a .tex file that directly draws the image is inserted, something like \chapterimage{\input{pascal.tex}} this because if only one image is included it loses quality.

Edited 2: Main file

\documentclass[12pt,fleqn,x11names,table,openany,usenames,dvipsnames]{book}                                                  
% Dimensiones y márgenes.                                                 
\usepackage[top=2cm,bottom=1.5cm,left=2.5cm,right=2.5cm,headsep=10pt,letterpaper]{geometry} 

%----------------------------------------------------------------------
\input{Preambulo}% = Paquetes y código de diseño
%----------------------------------------------------------------------

\begin{document}

%---------------------------------------------------------------------------------
%   Tabla de contenidos
%---------------------------------------------------------------------------------

\chapterimage{imagen4.png} % Foto en tabla de contenidos
\pagestyle{empty}          % Pág sin encabezado
\tableofcontents 

\cleardoublepage  %
\pagestyle{fancy} % Encabezados

%---------------------------------------------------------------------------------
%   Capítulo 1
%---------------------------------------------------------------------------------

\chapterimage{imagen4.png} 
\chapter{Estadística y probabilidad}

\section{Estadística}

Para datos no agrupados.

\subsection{Conceptos básicos}

Text text text 

\end{document}

File called Preambulo

%--------------------------------------------------------------------------
% Paquetes y estilo del libro 
%--------------------------------------------------------------------------
% Paquetes 
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}                      % Entrada de acentos
\usepackage[T1]{fontenc}
\usepackage[autostyle, spanish = mexican]{csquotes}% manejo de comillas: ``__ "
\linespread{1.05}                                  % Fuente Palatino necesita espaciado
\usepackage[full]{textcomp}                        % Caracteres especiales como ' (recto)
\usepackage{xcolor}                                % Color: X11names (en el documentclass)
\usepackage{ifsym}          %número digitales
% COLORES personales---http://latexcolor.com/---------------------------------
    \definecolor{colortitulo}{RGB}{219,68,14} % 
    \definecolor{colordominante}{RGB}{243,102,25}
    \definecolor{colordominanteF}{RGB}{219,68,14}
    \definecolor{colordominanteD}{RGB}{137,46,55}
    \definecolor{mostaza}{RGB}{231,196,25}
    \definecolor{amarilloM}{RGB}{248,199,90}
    \definecolor{amarilloD}{RGB}{251,237,121}
    \definecolor{grisamarillo}{RGB}{248,248,245} 
    \definecolor{azulF}{rgb}{.0,.0,.3}
    \definecolor{grisD}{rgb}{.3,.3,.3}
    \definecolor{grisF}{rgb}{.6,.6,.6}

% Fin COLORES personales-------------------------------------------------

\usepackage{xparse}
\usepackage[most]{tcolorbox}                             % Cajas de Teoremas, ejemplos, etc.
\tcbuselibrary{skins,breakable}                    % Librerías tcolorbox
\usepackage{xargs}                                 % Comandos con opciones
\usetikzlibrary{positioning,shadows,backgrounds,calc}%
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsfonts,latexsym,cancel,stmaryrd,amsthm}%
\usepackage[ruled,,vlined,lined,linesnumbered,algochapter]{algorithm2e}
\usepackage{framed}
\usepackage{titletoc}
\usepackage{etoolbox}
%\usepackage{epstopdf}% Conversión - Miktes 2.9 o inferior, TexLive 2009. o inferior
\usepackage[small,bf]{caption}
\usepackage[breaklinks,colorlinks=true, pdfstartview=FitV, linkcolor=azulF,
citecolor=azulF, urlcolor=azulF]{hyperref}
\usepackage[shortlabels]{enumitem}

%Animaciones
\usepackage{pgf,tikz,pgfplots}
\usetikzlibrary{quotes}
\usetikzlibrary{babel}
\usepackage{animate}
\usetikzlibrary{lindenmayersystems}
\pgfplotsset{compat=1.16}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,backgrounds}

%---------------------------------------------------------------------------------
% Fuentes
%---------------------------------------------------------------------------------

% Comandos para fuentes especiales
\newcommandx*{\fnte}[4][1=pag,2=9,3=n]{{\color{azulF}\fontfamily{#1}\fontsize{#2}{1}\fontshape{#3}\selectfont{#4}}}

\newcommandx*{\fntb}[4][1=pag,2=9,3=n]{{\color{azulF}\fontfamily{#1}\fontsize{#2}{1}\fontseries{b}\fontshape{#3}\selectfont{#4}}}

\newcommandx*{\fntg}[4][1=pag,2=9,3=n]{{\color{grisF}\fontfamily{#1}\fontsize{#2}{1}\fontshape{#3}\selectfont{#4}}}

\newcommand{\fhv}[2]{{\fontfamily{pag}\fontsize{#1}{1}\selectfont{#2}}}

\newcommand{\fhvb}[2]{{\fontfamily{pag}\fontseries{b}\fontsize{#1}{1}\selectfont{#2}}}
% Fin fuentes----------------------------------------------------------



%---------------------------------------------------------------------------------
%tabla de contenidofotos
%---------------------------------------------------------------------------------

\usepackage{titlesec} % Permite la personalización de títulos
\usepackage{graphicx} % Requerido para la inclusión de imágenes
\setlist{nolistsep} % Reducir el espacio entre las viñetas y listas numeradas
\usepackage{booktabs} % Necesario para reglas horizontales más bonitas en las tablas
\usepackage{eso-pic} % Requerido para especificar una imagen de fondo en la página del título

%----------------------------------------------------------------------------------------
%   Tabla de contenidos
%----------------------------------------------------------------------------------------

\usepackage{titletoc} % Necesario para manipular la tabla de contenido

\contentsmargin{0cm} % Elimina el margen predeterminado
% Estilo del texto en "Capítulo"
\titlecontents{chapter}[1.25cm] % Indentación
{\addvspace{15pt}\large\sffamily\bfseries} % Espaciado y fuente, opciones de capítulos
{\color{colordominante!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{colordominante}} % Chapter number
{}  
{\color{colordominante!60}\normalsize\sffamily\bfseries\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
% Estilo del texto Sección
\titlecontents{section}[1.25cm] % Indentación
{\addvspace{5pt}\sffamily\bfseries} % Espaciado y fuente, opciones de las secciones
{\contentslabel[\thecontentslabel]{1.25cm}} % Section number
{}
{\sffamily\hfill\color{black}\thecontentspage} % Page number
[]
% Estilo del texto Subsección
\titlecontents{subsection}[1.25cm] % Indentación
{\addvspace{1pt}\sffamily\small} % Espaciado y fuente opciones para las subsecciones
{\contentslabel[\thecontentslabel]{1.25cm}} % Subsection number
{}
{\sffamily\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
[] 

%----------------------------------------------------------------------------------------
%   MINI TABLA DE CONTENIDO DE CADA CAPÍTULO
%----------------------------------------------------------------------------------------

% Section text styling
\titlecontents{lsection}[0em] % Indentando
{\footnotesize\sffamily}      % Fuentes
{}
{}
{}

% Estilo del texto Subsección
\titlecontents{lsubsection}[.5em]   % Indentando
{\normalfont\footnotesize\sffamily} % Fuentes
{}
{}
{}

%----------------------------------------------------------------------------------------
%   Encabezados de página
%----------------------------------------------------------------------------------------

\usepackage{fancyhdr} %Necesario para la cabecera y el pie de página de configuración
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries #1}{}} % Fuente capítulo
% Texto en secciones
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} 
% Configuración de fuentes para el número de página en el encabezado
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} 
\fancyhead[LO]{\rightmark} %
\fancyhead[RE]{\leftmark} % 
\renewcommand{\headrulewidth}{0.5pt} % Ancho de la norma bajo el encabezado
\addtolength{\headheight}{2.5pt} % Aumente el espacio alrededor de la cabecera 
\renewcommand{\footrulewidth}{0pt} % Elimina la línea en el pie de página
% Estilo para cuando se especifica "pagestyle plain"
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} 

% Elimina el encabezado de las páginas impares vacías al final de los capítulos
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}


%---------------------------------------------------------------------------------
%   Numeración de las secciones -- en el margen
%---------------------------------------------------------------------------------

\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{colordominante}{\csname the#1\endcsname}\hspace{1em}}}                    
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{0.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}                        
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{0.1ex}
{\normalfont\small\sffamily\bfseries}}

%---------------------------------------------------------------------------------
%   Diseño inicio de capítulos
%---------------------------------------------------------------------------------

\newcommand{\thechapterimage}{}
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}
\def\thechapter{\arabic{chapter}}
\def\@makechapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]

\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};

%Comentando las 3 líneas de abajo quita la caja de contenidos en el título del capítulo
\draw[rounded corners=10pt, fill=white,opacity=0.5] (1cm,0cm) rectangle (8cm,-7.0cm);                   %%%%%%%%%%%%%%%%%%% minitabla
\node[anchor=north west] at (1cm,.25cm) {\parbox[t][8cm][t]{6.5cm}{\huge\bfseries\flushleft \printcontents{l}{1}{\setcounter{tocdepth}{2}}}};

\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,fill=white,fill opacity=.6,text opacity=1,draw=colordominante,draw opacity=1,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{\thechapter\ ---\ #1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\def\@makeschapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west] at (-4pt,4pt) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (5cm,-9.cm) node [rounded corners=25pt,fill=white,opacity=.6,inner sep=18pt]{\huge\sffamily\bfseries\textcolor{black}{\vphantom{plPQq}\makebox[22cm]{}}};
\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{#1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\makeatother

Image

enter image description here

File called pascal that I want to include in place of the image, something like (\chapterimage{\input{pascal}})

\documentclass{standalone}%

\usepackage[dvipsnames]{xcolor} 
\usepackage{tikz}
\usepackage{ifthen}
\makeatletter
\newcommand\binomialCoefficient[2]{%
    % Store values 
    \c@pgf@counta=#1% n
    \c@pgf@countb=#2% k
    %
    % Take advantage of symmetry if k > n - k
    \c@pgf@countc=\c@pgf@counta%
    \advance\c@pgf@countc by-\c@pgf@countb%
    \ifnum\c@pgf@countb>\c@pgf@countc%
        \c@pgf@countb=\c@pgf@countc%
    \fi%
    %
    % Recursively compute the coefficients
    \c@pgf@countc=1% will hold the result
    \c@pgf@countd=0% counter
    \pgfmathloop% c -> c*(n-i)/(i+1) for i=0,...,k-1
        \ifnum\c@pgf@countd<\c@pgf@countb%
        \multiply\c@pgf@countc by\c@pgf@counta%
        \advance\c@pgf@counta by-1%
        \advance\c@pgf@countd by1%
        \divide\c@pgf@countc by\c@pgf@countd%
    \repeatpgfmathloop%
    \the\c@pgf@countc%
}
\makeatother
\begin{document}
\newdimen\R
\R=.4cm
\newcommand\mycolor{gray}

\begin{tikzpicture}[line width=.8pt]
\fill[cyan!50] (-460pt,-270pt) rectangle (140pt,30pt);

  \foreach \k in {0,...,12}{
    \begin{scope}[shift={(-60:{sqrt(3)*\R*\k})}]
      \pgfmathtruncatemacro\ystart{12-\k}
      \foreach \n in {0,...,\ystart}{
        \pgfmathtruncatemacro\newn{\n+\k}
        \ifthenelse{\k=0}{\def\mycolor{pink}}{}
        \ifthenelse{\k=1}{\def\mycolor{yellow}}{}
        \ifthenelse{\k=2}{\def\mycolor{blue}}{}
        \ifthenelse{\k=3}{\def\mycolor{green}}{}
        \ifthenelse{\k=8 \AND \n < 4}{\def\mycolor{purple}}{}
        \ifthenelse{\k=9 \AND \n = 3}{\def\mycolor{purple}}{}
        \begin{scope}[shift={(-120:{sqrt(3)*\R*\n})}]
           \draw[top color=\mycolor!20,bottom color=\mycolor!60] 
             (30:\R) \foreach \x in {90,150,...,330} {
                -- (\x:\R)}
                -- cycle (90:0)
                   node {\tiny $\mathbf{\binomialCoefficient{\newn}{\k}}$};
         \end{scope}
      }
    \end{scope}
  }
\end{tikzpicture} 
\end{document}
  • Please provide us with a full compilable code. Note that you are nesting tikzpictures (by putting a tikzpicture into the node of another tikzpicture), which should be avoided. Also I am wondering why this is tagged tikz-external (rather than just tikz-pgf). – marmot Dec 3 '18 at 23:02
  • 1
    Sorry, many users here, including myself, do not follow external links. Please just edit your code such that it starts with \documentclass, ends with \end{document}, can be compiled and illustrates what you want. And if you want make your question read by TikZ users, avoid nesting tikzpictures as this has consequences that are hard to control. – marmot Dec 3 '18 at 23:48
  • @marmot excuse the delay, I simplified the files as far as I could. – Samuel Diaz Dec 4 '18 at 14:13
3

I am not sure if this qualifies as an answer. However, if you do not convert your self-created image to png put just keep it in the pdf format, there won't be any quality loss.

The reason why I am posting an answer here is to tell you that you should really not nest tikzpictures. And there is no need for it either. You could just use this great answer to put whatever on top of your included graphics. Specifically, there is a local coordinate system coming with that answer which makes the placement a bit more intuitive. (Note that here because of the absolute positioning and the fact that the north west anchor is used, y becomes larger when moving down.) Your Preambulo.tex file then becomes

%--------------------------------------------------------------------------
% Paquetes y estilo del libro 
%--------------------------------------------------------------------------
% Paquetes 
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}                      % Entrada de acentos
\usepackage[T1]{fontenc}
\usepackage[autostyle, spanish = mexican]{csquotes}% manejo de comillas: ``__ "
\linespread{1.05}                                  % Fuente Palatino necesita espaciado
\usepackage[full]{textcomp}                        % Caracteres especiales como ' (recto)
\usepackage{xcolor}                                % Color: X11names (en el documentclass)
\usepackage{ifsym}          %número digitales
% COLORES personales---http://latexcolor.com/---------------------------------
    \definecolor{colortitulo}{RGB}{219,68,14} % 
    \definecolor{colordominante}{RGB}{243,102,25}
    \definecolor{colordominanteF}{RGB}{219,68,14}
    \definecolor{colordominanteD}{RGB}{137,46,55}
    \definecolor{mostaza}{RGB}{231,196,25}
    \definecolor{amarilloM}{RGB}{248,199,90}
    \definecolor{amarilloD}{RGB}{251,237,121}
    \definecolor{grisamarillo}{RGB}{248,248,245} 
    \definecolor{azulF}{rgb}{.0,.0,.3}
    \definecolor{grisD}{rgb}{.3,.3,.3}
    \definecolor{grisF}{rgb}{.6,.6,.6}

% Fin COLORES personales-------------------------------------------------

\usepackage{xparse}
\usepackage[most]{tcolorbox}                             % Cajas de Teoremas, ejemplos, etc.
\tcbuselibrary{skins,breakable}                    % Librerías tcolorbox
\usepackage{xargs}                                 % Comandos con opciones
\usetikzlibrary{positioning,shadows,backgrounds,calc}%
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsfonts,latexsym,cancel,stmaryrd,amsthm}%
\usepackage[ruled,,vlined,lined,linesnumbered,algochapter]{algorithm2e}
\usepackage{framed}
\usepackage{titletoc}
\usepackage{etoolbox}
%\usepackage{epstopdf}% Conversión - Miktes 2.9 o inferior, TexLive 2009. o inferior
\usepackage[small,bf]{caption}
\usepackage[breaklinks,colorlinks=true, pdfstartview=FitV, linkcolor=azulF,
citecolor=azulF, urlcolor=azulF]{hyperref}
\usepackage[shortlabels]{enumitem}

%Animaciones
\usepackage{pgf,tikz,pgfplots}
\usetikzlibrary{quotes}
\usetikzlibrary{babel}
\usepackage{animate}
\usetikzlibrary{lindenmayersystems}
\pgfplotsset{compat=1.16}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,backgrounds}

%---------------------------------------------------------------------------------
% Fuentes
%---------------------------------------------------------------------------------

% Comandos para fuentes especiales
\newcommandx*{\fnte}[4][1=pag,2=9,3=n]{{\color{azulF}\fontfamily{#1}\fontsize{#2}{1}\fontshape{#3}\selectfont{#4}}}

\newcommandx*{\fntb}[4][1=pag,2=9,3=n]{{\color{azulF}\fontfamily{#1}\fontsize{#2}{1}\fontseries{b}\fontshape{#3}\selectfont{#4}}}

\newcommandx*{\fntg}[4][1=pag,2=9,3=n]{{\color{grisF}\fontfamily{#1}\fontsize{#2}{1}\fontshape{#3}\selectfont{#4}}}

\newcommand{\fhv}[2]{{\fontfamily{pag}\fontsize{#1}{1}\selectfont{#2}}}

\newcommand{\fhvb}[2]{{\fontfamily{pag}\fontseries{b}\fontsize{#1}{1}\selectfont{#2}}}
% Fin fuentes----------------------------------------------------------



%---------------------------------------------------------------------------------
%tabla de contenidofotos
%---------------------------------------------------------------------------------

\usepackage{titlesec} % Permite la personalización de títulos
\usepackage{graphicx} % Requerido para la inclusión de imágenes
\setlist{nolistsep} % Reducir el espacio entre las viñetas y listas numeradas
\usepackage{booktabs} % Necesario para reglas horizontales más bonitas en las tablas
\usepackage{eso-pic} % Requerido para especificar una imagen de fondo en la página del título

%----------------------------------------------------------------------------------------
%   Tabla de contenidos
%----------------------------------------------------------------------------------------

\usepackage{titletoc} % Necesario para manipular la tabla de contenido

\contentsmargin{0cm} % Elimina el margen predeterminado
% Estilo del texto en "Capítulo"
\titlecontents{chapter}[1.25cm] % Indentación
{\addvspace{15pt}\large\sffamily\bfseries} % Espaciado y fuente, opciones de capítulos
{\color{colordominante!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{colordominante}} % Chapter number
{}  
{\color{colordominante!60}\normalsize\sffamily\bfseries\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
% Estilo del texto Sección
\titlecontents{section}[1.25cm] % Indentación
{\addvspace{5pt}\sffamily\bfseries} % Espaciado y fuente, opciones de las secciones
{\contentslabel[\thecontentslabel]{1.25cm}} % Section number
{}
{\sffamily\hfill\color{black}\thecontentspage} % Page number
[]
% Estilo del texto Subsección
\titlecontents{subsection}[1.25cm] % Indentación
{\addvspace{1pt}\sffamily\small} % Espaciado y fuente opciones para las subsecciones
{\contentslabel[\thecontentslabel]{1.25cm}} % Subsection number
{}
{\sffamily\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number
[] 

%----------------------------------------------------------------------------------------
%   MINI TABLA DE CONTENIDO DE CADA CAPÍTULO
%----------------------------------------------------------------------------------------

% Section text styling
\titlecontents{lsection}[0em] % Indentando
{\footnotesize\sffamily}      % Fuentes
{}
{}
{}

% Estilo del texto Subsección
\titlecontents{lsubsection}[.5em]   % Indentando
{\normalfont\footnotesize\sffamily} % Fuentes
{}
{}
{}

%----------------------------------------------------------------------------------------
%   Encabezados de página
%----------------------------------------------------------------------------------------

\usepackage{fancyhdr} %Necesario para la cabecera y el pie de página de configuración
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries #1}{}} % Fuente capítulo
% Texto en secciones
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} 
% Configuración de fuentes para el número de página en el encabezado
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} 
\fancyhead[LO]{\rightmark} %
\fancyhead[RE]{\leftmark} % 
\renewcommand{\headrulewidth}{0.5pt} % Ancho de la norma bajo el encabezado
\addtolength{\headheight}{2.5pt} % Aumente el espacio alrededor de la cabecera 
\renewcommand{\footrulewidth}{0pt} % Elimina la línea en el pie de página
% Estilo para cuando se especifica "pagestyle plain"
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} 

% Elimina el encabezado de las páginas impares vacías al final de los capítulos
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}


%---------------------------------------------------------------------------------
%   Numeración de las secciones -- en el margen
%---------------------------------------------------------------------------------

\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{colordominante}{\csname the#1\endcsname}\hspace{1em}}}                    
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{0.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}                        
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{0.1ex}
{\normalfont\small\sffamily\bfseries}}

%---------------------------------------------------------------------------------
%   Diseño inicio de capítulos
%---------------------------------------------------------------------------------

\newcommand{\thechapterimage}{}
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}
\def\thechapter{\arabic{chapter}}
\def\@makechapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west,inner sep=0pt] (image) at (current page.north west)
{\includegraphics[width=\paperwidth]{\thechapterimage}};
\begin{scope}[shift={([xshift=-4pt,yshift=4pt]current page.north
west)},x={(image.north east)},y={(image.south west)}]
%Comentando las 3 líneas de abajo quita la caja de contenidos en el título del capítulo
 \node[anchor=north west,rounded corners=10pt, fill=white,opacity=0.5] at 
 (0.05,0.1) {\parbox[t][8cm][t]{6.5cm}{\huge\bfseries\flushleft \printcontents{l}{1}{\setcounter{tocdepth}{2}}}};
 \draw[anchor=west] (0.2,0.8) node [rounded corners=25pt,fill=white,fill opacity=.6,text opacity=1,draw=colordominante,draw opacity=1,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{\thechapter\ ---\ #1\vphantom{plPQq}\makebox[22cm]{}}};
\end{scope}
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\def\@makeschapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay] % https://tex.stackexchange.com/a/9562/121799
\node[anchor=north west] (image) at ([xshift=-4pt,yshift=4pt]current page.north west)
{\includegraphics[width=\paperwidth]{\thechapterimage}};
\begin{scope}[shift={([xshift=-4pt,yshift=4pt]current page.north
west)},x={(image.north east)},y={(image.south west)}]
 \draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,fill=white,opacity=.6,inner sep=18pt]{\huge\sffamily\bfseries\textcolor{black}{\vphantom{plPQq}\makebox[22cm]{}}};
 \draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{#1\vphantom{plPQq}\makebox[22cm]{}}};
\end{scope}
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\makeatother

enter image description here

Whether or not these are the precise locations of the title and the table of contents, I don't know, but with Jake's local coordinate system that is being used here it should be straightforward to move things to the desired position.

  • did not know that PDFs maintain the quality of the images, I'm left with this solution is simple and efficient, thank you very much. – Samuel Diaz Dec 4 '18 at 20:08
  • @SamuelDiaz You're welcome! – marmot Dec 4 '18 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.