1

I'm making a book of poems and I'd like to add some specif style to the pages. So I use fancyhdr And everything goes right until I add \usepackage[utf8]{inputenc}

This is the code I use

\documentclass{book}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{titlesec}

\input{Recursos/poem-template.tex}


% aqui definimos el encabezado de las paginas pares e impares.
\lhead[x1\begin{picture}(0,0)\put(-50,-693){\includegraphics[width=0.125in,height=11in]{Gráficos/orange.png}} \end{picture}]{x2}
\chead[y1]{y2}
\rhead[z1]{z2\begin{picture}(0,0)\put(50,-693){\includegraphics[width=0.125in,height=11in]{Gráficos/orange.png}} \end{picture}}
\renewcommand{\headrulewidth}{0pt}

% aqui definimos el encabezado y pie de pagina de la pagina inicial de un capitulo.
\fancypagestyle{plain}{
    \fancyhead[L]{K1\begin{picture}(0,0)\put(-106,-75){\includegraphics[width=8.5in,height=1in]{Gráficos/orange.png}K1} \end{picture}}
    \fancyhead[C]{K2}
    \fancyhead[R]{K3}
    \renewcommand{\headrulewidth}{0pt}
}
\pagestyle{fancy}

\begin{document}

\titleformat{\chapter}[display]
{\large\scshape\centering}{}{0pt}{\large}
\titlespacing*{\chapter}{0pt}{*0}{0pt}

\poem{Poem-sample}{dd/mm/aaaa}{poem-sample.tex}

\end{document}

This is the file poem-sample.tex

\centering
Proin laoreet 
felis vitae 
mollis volutpat.

In ac dolor id
nulla consectetur faucibus.

Nam ultrices mi non 
quam tempor tristique.

Aenean sed urna dapibus, 
hendrerit magna non,
porttitor sapien.

Vivamus sed lorem 
sit amet est 
scelerisque mattis.
Ut ac elit at dui 
feugiat pulvinar.

Etiam efficitur 
ex in facilisis porta.
Mauris viverra libero 
nec justo ullamcorper, 
ac laoreet odio ultrices.

Fusce in odio at erat 
pharetra hendrerit.

Praesent fringilla 
erat ut velit pellentesque, 
nec bibendum mi lobortis.

Aliquam convallis 
enim vel convallis ornare.

In molestie mauris
quis enim ornare efficitur.

Cras faucibus tellus 
eu justo tincidunt varius.

Aenean vel risus 
ac urna vehicula mollis 
in sit amet justo.

Praesent nec nulla 
id purus hendrerit 
efficitur ac vel felis.

And this is the poem-template.tex

\newcommand{\poem}[3]{\chapter{#1}\centering\small\textit{#2}\\[0.05in]\normalsize\verseinput{"Contenido/texto/#3"}}

\begingroup
\makeatletter
\catcode13\active%
\gdef\verseinput#1{%
{%
\interlinepenalty\@M%
\def^^M{\@ifnextchar^^M\par{\ifhmode\break\fi}}%
\rightskip\fill%
\parindent\z@%
\parskip\baselineskip%
\raggedbottom%
\catcode13\active\input{#1}%
\par%
}}%
\endgroup%

I'm using MiKTeX, I think it is the problem

4
  • 2
    Welcome to TeX SX! I use MiKTeX with utf8 encoding, and typed a few poems , and never had a problem…
    – Bernard
    Oct 19, 2015 at 0:58
  • Thaks! The problem is not with the poems, it is with the image in headers. But I don't know why. Oct 19, 2015 at 1:02
  • 1
    And what is the poem-template file?
    – Bernard
    Oct 19, 2015 at 1:29
  • poem-template is the last code, thanks I already found the solution. Oct 19, 2015 at 1:48

1 Answer 1

1

I do not think that adding \usepackage[utf8]{inputenc} is a problem for your code.

The real problem is that you have non ascii signs in your file path, for example: Gráficos/orange.png.

With the following MWE I can run your code without errors or warnings. I just deactivated your faulty path for the graphic files with option [demo] for package graphicx:

\RequirePackage{filecontents}
\begin{filecontents}{poem-sample.tex}
\centering
Proin laoreet 
felis vitae 
mollis volutpat.

In ac dolor id
nulla consectetur faucibus.

Nam ultrices mi non 
quam tempor tristique.

Aenean sed urna dapibus, 
hendrerit magna non,
porttitor sapien.

Vivamus sed lorem 
sit amet est 
scelerisque mattis.
Ut ac elit at dui 
feugiat pulvinar.

Etiam efficitur 
ex in facilisis porta.
Mauris viverra libero 
nec justo ullamcorper, 
ac laoreet odio ultrices.

Fusce in odio at erat 
pharetra hendrerit.

Praesent fringilla 
erat ut velit pellentesque, 
nec bibendum mi lobortis.

Aliquam convallis 
enim vel convallis ornare.

In molestie mauris
quis enim ornare efficitur.

Cras faucibus tellus 
eu justo tincidunt varius.

Aenean vel risus 
ac urna vehicula mollis 
in sit amet justo.

Praesent nec nulla 
id purus hendrerit 
efficitur ac vel felis.
\end{filecontents}


\documentclass{book}

\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{fancyhdr}
\usepackage{titlesec}

\newcommand{\poem}[3]{\chapter{#1}\centering\small\textit{#2}\\[0.05in]\normalsize\verseinput{"#3"}}% <==============================

\begingroup
\makeatletter
\catcode13\active%
\gdef\verseinput#1{%
{%
\interlinepenalty\@M%
\def^^M{\@ifnextchar^^M\par{\ifhmode\break\fi}}%
\rightskip\fill%
\parindent\z@%
\parskip\baselineskip%
\raggedbottom%
\catcode13\active\input{#1}%
\par%
}}%
\endgroup%


% aqui definimos el encabezado de las paginas pares e impares.
\lhead[x1\begin{picture}(0,0)\put(-50,-693){\includegraphics[width=0.125in,height=11in]{Gráficos/orange.png}} \end{picture}]{x2}
\chead[y1]{y2}
\rhead[z1]{z2\begin{picture}(0,0)\put(50,-693){\includegraphics[width=0.125in,height=11in]{Gráficos/orange.png}} \end{picture}}
\renewcommand{\headrulewidth}{0pt}

% aqui definimos el encabezado y pie de pagina de la pagina inicial de un capitulo.
\fancypagestyle{plain}{
    \fancyhead[L]{K1\begin{picture}(0,0)\put(-106,-75){\includegraphics[width=8.5in,height=1in]{Gráficos/orange.png}K1} \end{picture}}
    \fancyhead[C]{K2}
    \fancyhead[R]{K3}
    \renewcommand{\headrulewidth}{0pt}
}
\pagestyle{fancy}


\begin{document}

\titleformat{\chapter}[display]
{\large\scshape\centering}{}{0pt}{\large}
\titlespacing*{\chapter}{0pt}{*0}{0pt}

\poem{Poem-sample}{dd/mm/aaaa}{poem-sample.tex}

\end{document}

and the result:

enter image description here

Please see that I changed your command \poem:

\newcommand{\poem}[3]{\chapter{#1}\centering\small\textit{#2}\\[0.05in]\normalsize\verseinput{"#3"}}% <==============================
1
  • Yeah!! It was a problem with my file path. Now everthing goes perfect. Thank you so much! Oct 19, 2015 at 1:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .