3

I'd like to write a document using this template : http://phd.epfl.ch/modelesthese. When i'm compiling with pdflatex, there's no problem and the chapter headers are fine.

Here is a MWE :

\documentclass[a4paper,11pt,fleqn]{book}

\usepackage{tikz}
\usepackage[explicit]{titlesec}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
  \node[yshift=-8cm] at (current page.north west)
  {\begin{tikzpicture}[remember picture, overlay]
    \draw[fill=black] (0,0) rectangle(35.5mm,15mm);
    \node[anchor=north west,yshift=-7.2cm,xshift=37mm,text width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north west)
    {\parbox[top][30mm][t]{\textwidth}{Chapter One}};
  \end{tikzpicture}};
\end{tikzpicture}
\end{document}

But with xetex, there is an issue with the chapter header. The position of the text isn't good.

With pdflatex :

enter image description here

With xelatex :

enter image description here

Does anyone know why and how to fix it?

  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Symbol 1 Mar 5 '15 at 13:27
  • I compiled the template given at phd.epfl.ch both with pdflatex and xelatex. It produced the same result (after I removed inputenc package for xelatex) – JLDiaz Mar 5 '15 at 15:37
  • Are you aware that nesting TikZ pictures is known to cause problems? Sometimes you can get away with it, but often not. Why do you need to nest pictures here? I don't understand the purpose. – cfr Mar 5 '15 at 23:36
  • 1
    Already an answer is given, but anyway pgf drivers for XeTeX are known to have bugs, which Ulrike knows better. For the present example, the following gives the same results between pdflatex and xelatex: \documentclass[a4paper,11pt,fleqn]{book} \ifx\XeTeXpdffile\undefined\else \newcount\pdftexversion \pdftexversion140 \def\pgfsysdriver{pgfsys-dvipdfm.def} \fi \usepackage{tikz} \usepackage[explicit]{titlesec} \begin{document} ... \end{document} – Akira Kakuto Mar 6 '15 at 0:10
2

How about something like this which avoids nesting pictures? It uses the positioning and calc libraries to position things:

\documentclass[a4paper,11pt,fleqn]{book}

\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage[explicit]{titlesec}

\begin{document}

  \begin{tikzpicture}[remember picture,overlay]
    \coordinate [below=80mm of current page.north west] (a);
    \draw[fill=black] ($(a) + (0,7.5mm)$) rectangle ($(a) + (35.5mm,-7.5mm)$);
    \node[anchor=north west, right=37mm of a, text width=\textwidth, minimum height=30mm, inner sep=0mm]
        {Chapter One};
  \end{tikzpicture}
\end{document}

output

[I get the same output with XeLaTeX and pdfLaTeX.]

| improve this answer | |
  • @user3350813 Don't forget to consider accepting the answer if it solves the problem so that other users can see the question has a solution. – cfr Mar 7 '15 at 15:52

Your Answer

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

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