Include tikz image in other text files of each chapter











up vote
3
down vote

favorite












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}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}


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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
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
newcommandbinomialCoefficient[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%
advancec@pgf@countc by-c@pgf@countb%
ifnumc@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
ifnumc@pgf@countd<c@pgf@countb%
multiplyc@pgf@countc byc@pgf@counta%
advancec@pgf@counta by-1%
advancec@pgf@countd by1%
dividec@pgf@countc byc@pgf@countd%
repeatpgfmathloop%
thec@pgf@countc%
}
makeatother
begin{document}
newdimenR
R=.4cm
newcommandmycolor{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})}]
pgfmathtruncatemacroystart{12-k}
foreach n in {0,...,ystart}{
pgfmathtruncatemacronewn{n+k}
ifthenelse{k=0}{defmycolor{pink}}{}
ifthenelse{k=1}{defmycolor{yellow}}{}
ifthenelse{k=2}{defmycolor{blue}}{}
ifthenelse{k=3}{defmycolor{green}}{}
ifthenelse{k=8 AND n < 4}{defmycolor{purple}}{}
ifthenelse{k=9 AND n = 3}{defmycolor{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}









share|improve this question
























  • 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 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 at 23:48










  • @marmot excuse the delay, I simplified the files as far as I could.
    – Samuel Diaz
    Dec 4 at 14:13















up vote
3
down vote

favorite












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}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}


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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
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
newcommandbinomialCoefficient[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%
advancec@pgf@countc by-c@pgf@countb%
ifnumc@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
ifnumc@pgf@countd<c@pgf@countb%
multiplyc@pgf@countc byc@pgf@counta%
advancec@pgf@counta by-1%
advancec@pgf@countd by1%
dividec@pgf@countc byc@pgf@countd%
repeatpgfmathloop%
thec@pgf@countc%
}
makeatother
begin{document}
newdimenR
R=.4cm
newcommandmycolor{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})}]
pgfmathtruncatemacroystart{12-k}
foreach n in {0,...,ystart}{
pgfmathtruncatemacronewn{n+k}
ifthenelse{k=0}{defmycolor{pink}}{}
ifthenelse{k=1}{defmycolor{yellow}}{}
ifthenelse{k=2}{defmycolor{blue}}{}
ifthenelse{k=3}{defmycolor{green}}{}
ifthenelse{k=8 AND n < 4}{defmycolor{purple}}{}
ifthenelse{k=9 AND n = 3}{defmycolor{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}









share|improve this question
























  • 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 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 at 23:48










  • @marmot excuse the delay, I simplified the files as far as I could.
    – Samuel Diaz
    Dec 4 at 14:13













up vote
3
down vote

favorite









up vote
3
down vote

favorite











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}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}


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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
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
newcommandbinomialCoefficient[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%
advancec@pgf@countc by-c@pgf@countb%
ifnumc@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
ifnumc@pgf@countd<c@pgf@countb%
multiplyc@pgf@countc byc@pgf@counta%
advancec@pgf@counta by-1%
advancec@pgf@countd by1%
dividec@pgf@countc byc@pgf@countd%
repeatpgfmathloop%
thec@pgf@countc%
}
makeatother
begin{document}
newdimenR
R=.4cm
newcommandmycolor{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})}]
pgfmathtruncatemacroystart{12-k}
foreach n in {0,...,ystart}{
pgfmathtruncatemacronewn{n+k}
ifthenelse{k=0}{defmycolor{pink}}{}
ifthenelse{k=1}{defmycolor{yellow}}{}
ifthenelse{k=2}{defmycolor{blue}}{}
ifthenelse{k=3}{defmycolor{green}}{}
ifthenelse{k=8 AND n < 4}{defmycolor{purple}}{}
ifthenelse{k=9 AND n = 3}{defmycolor{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}









share|improve this question















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}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}


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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{tikzpicture}};
end{tikzpicture}}parvspace*{230p@}
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
newcommandbinomialCoefficient[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%
advancec@pgf@countc by-c@pgf@countb%
ifnumc@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
ifnumc@pgf@countd<c@pgf@countb%
multiplyc@pgf@countc byc@pgf@counta%
advancec@pgf@counta by-1%
advancec@pgf@countd by1%
dividec@pgf@countc byc@pgf@countd%
repeatpgfmathloop%
thec@pgf@countc%
}
makeatother
begin{document}
newdimenR
R=.4cm
newcommandmycolor{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})}]
pgfmathtruncatemacroystart{12-k}
foreach n in {0,...,ystart}{
pgfmathtruncatemacronewn{n+k}
ifthenelse{k=0}{defmycolor{pink}}{}
ifthenelse{k=1}{defmycolor{yellow}}{}
ifthenelse{k=2}{defmycolor{blue}}{}
ifthenelse{k=3}{defmycolor{green}}{}
ifthenelse{k=8 AND n < 4}{defmycolor{purple}}{}
ifthenelse{k=9 AND n = 3}{defmycolor{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}






macros sectioning chapters tikz-external






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 4 at 14:11

























asked Dec 3 at 22:59









Samuel Diaz

28618




28618












  • 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 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 at 23:48










  • @marmot excuse the delay, I simplified the files as far as I could.
    – Samuel Diaz
    Dec 4 at 14:13


















  • 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 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 at 23:48










  • @marmot excuse the delay, I simplified the files as far as I could.
    – Samuel Diaz
    Dec 4 at 14:13
















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 at 23:02






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 at 23:02






1




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 at 23:48




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 at 23:48












@marmot excuse the delay, I simplified the files as far as I could.
– Samuel Diaz
Dec 4 at 14:13




@marmot excuse the delay, I simplified the files as far as I could.
– Samuel Diaz
Dec 4 at 14:13










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
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.






share|improve this answer





















  • 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 at 20:08










  • @SamuelDiaz You're welcome!
    – marmot
    Dec 4 at 20:09











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463061%2finclude-tikz-image-in-other-text-files-of-each-chapter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
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.






share|improve this answer





















  • 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 at 20:08










  • @SamuelDiaz You're welcome!
    – marmot
    Dec 4 at 20:09















up vote
3
down vote



accepted










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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
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.






share|improve this answer





















  • 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 at 20:08










  • @SamuelDiaz You're welcome!
    – marmot
    Dec 4 at 20:09













up vote
3
down vote



accepted







up vote
3
down vote



accepted






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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
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.






share|improve this answer












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}largesffamilybfseries} % Espaciado y fuente, opciones de capítulos
{color{colordominante!60}contentslabel[Largethecontentslabel]{1.25cm}color{colordominante}} % Chapter number
{}
{color{colordominante!60}normalsizesffamilybfseries;titlerule*[.5pc]{.};thecontentspage} % Page number
% Estilo del texto Sección
titlecontents{section}[1.25cm] % Indentación
{addvspace{5pt}sffamilybfseries} % Espaciado y fuente, opciones de las secciones
{contentslabel[thecontentslabel]{1.25cm}} % Section number
{}
{sffamilyhfillcolor{black}thecontentspage} % Page number

% Estilo del texto Subsección
titlecontents{subsection}[1.25cm] % Indentación
{addvspace{1pt}sffamilysmall} % 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
{footnotesizesffamily} % Fuentes
{}
{}
{}

% Estilo del texto Subsección
titlecontents{lsubsection}[.5em] % Indentando
{normalfontfootnotesizesffamily} % 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{sffamilynormalsizebfseries #1}{}} % Fuente capítulo
% Texto en secciones
renewcommand{sectionmark}[1]{markright{sffamilynormalsizethesectionhspace{5pt}#1}{}}
% Configuración de fuentes para el número de página en el encabezado
fancyhf{} fancyhead[LE,RO]{sffamilynormalsizethepage}
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}{
clearpageifoddc@pageelse
hbox{}
vspace*{fill}
thispagestyle{empty}
newpage
fi}


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

makeatletter
renewcommand{@seccntformat}[1]{llap{textcolor{colordominante}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseries}}
renewcommand{subsection}{@startsection {subsection}{2}{z@}
{-3ex @plus -0.1ex @minus -.4ex}
{0.5ex @plus.2ex }
{normalfontsffamilybfseries}}
renewcommand{subsubsection}{@startsection {subsubsection}{3}{z@}
{-2ex @plus -0.1ex @minus -.2ex}
{0.2ex @plus.2ex }
{normalfontsmallsffamilybfseries}}
renewcommandparagraph{@startsection{paragraph}{4}{z@}
{-2ex @plus-.2ex @minus .2ex}
{0.1ex}
{normalfontsmallsffamilybfseries}}

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

newcommand{thechapterimage}{}
newcommand{chapterimage}[1]{renewcommand{thechapterimage}{#1}}
defthechapter{arabic{chapter}}
def@makechapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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}{hugebfseriesflushleft 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]{hugesffamilybfseriestextcolor{black}{thechapter --- #1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
fi
fi
}
def@makeschapterhead#1{
thispagestyle{empty}
{centering normalfontsffamily
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]{hugesffamilybfseriestextcolor{black}{vphantom{plPQq}makebox[22cm]{}}};
draw[anchor=west] (0.2,0.4) node [rounded corners=25pt,draw=colordominante,line width=2pt,inner sep=15pt]{hugesffamilybfseriestextcolor{black}{#1vphantom{plPQq}makebox[22cm]{}}};
end{scope}
end{tikzpicture}}parvspace*{230p@}
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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 4 at 17:15









marmot

82.3k492175




82.3k492175












  • 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 at 20:08










  • @SamuelDiaz You're welcome!
    – marmot
    Dec 4 at 20:09


















  • 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 at 20:08










  • @SamuelDiaz You're welcome!
    – marmot
    Dec 4 at 20:09
















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 at 20:08




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 at 20:08












@SamuelDiaz You're welcome!
– marmot
Dec 4 at 20:09




@SamuelDiaz You're welcome!
– marmot
Dec 4 at 20:09


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463061%2finclude-tikz-image-in-other-text-files-of-each-chapter%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents