6

I want to create a titlepage with tikz and therefore I have a node within a title and a subtitle after a line-break. The problem now is, that something is wrong with the indentation, as you can see in the following picture. Both texts should start at the same position.

Problem

The compileable code example:

\documentclass[a5paper,11pt,twocolumn,parskip=half,parindent=none]{scrbook}
\usepackage[ngerman,german]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{lmodern}
\selectlanguage{german}
\usepackage{tikz}
\usepackage{color}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{helvet}
\definecolor{fsblue}{rgb}{0.17,0.24,0.31}
\definecolor{fsorange}{rgb}{1,0.44,0.0}
\renewcommand{\familydefault}{\sfdefault}
\geometry{top=25mm, left=15mm, right=12mm, bottom=20mm}
\begin{document}
\begin{tikzpicture}[remember picture,overlay,shift={(current page.south west)}]
\node [
  fill=fsorange,
  inner xsep=1em,
  minimum height=1cm,
  text width={\paperheight},
  anchor=north west,
  rotate=90
] at (current page.south west) {Text Text};
\node [
  fill=fsblue,
  inner xsep=1.5cm,
  minimum height=3cm,
  text width={\paperwidth-1cm},
  anchor=south west
] at (1cm,13cm) {\color{white}\bfseries\Huge B Text one\\\normalsize B Text two};
\end{tikzpicture}
\end{document}
  • 3
    Always better a full compilable example, not just the macro you are fiddling with. Welcome, in any case, to the site ;) – Manuel Jul 07 '15 at 20:33
  • Try with \Huge\@titlehead\\% I mean with a percentage sign at the end of the linebreak. – percusse Jul 07 '15 at 20:57
  • I think the problem here is the due to the different kerning for the letters. I mean, the title is in \huge font, but subject is in \normalsize. The boxes (which is what (La)TeX sees) for the initial letters are starting at the same point, but the glyphs themselves are slighlty offset. – Gonzalo Medina Jul 07 '15 at 21:03
  • @Manuel I added a full compilable example. Thanks for the advice and also hello :) – Jens Metzner Jul 07 '15 at 22:00
  • As I said before, the problem is just the kerning of the two "B"s in different sizes: use {\color{white}\bfseries\Huge\frame{B} Text one\\\normalsize\frame{B} Text two}; and you will see what I mean. – Gonzalo Medina Jul 07 '15 at 22:12
  • @GonzaloMedina Ok, I know what you mean. Thank you for the hint. Do you know if there is any solution to fix this? – Jens Metzner Jul 07 '15 at 23:06
  • @GonzaloMedina This is also called 'kerning'? I always think of that as between characters.... – cfr Jul 08 '15 at 10:17
  • @cfr Yes, kerning is used for adjustments between characters. However, I called it kerning because I don't know how else to call it. Do you happen to know the proper term to use in this situation? – Gonzalo Medina Jul 08 '15 at 13:28
  • @GonzaloMedina Sorry, no. I don't. That's why I wondered if it was also called 'kerning', although that seems unnecessarily confusing. – cfr Jul 08 '15 at 14:07

2 Answers2

4

Here's why there is no general solution to this:

\documentclass{article}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}

  \fbox{\Huge B}

  \fbox{B}

\end{document}

BB

The boxes are aligned perfectly. You are trying to align their content. But, to TeX, everything is a box. In particular, a B is just a box with particular dimensions. It can't take account of what is inside the box. It doesn't care what is inside the boxes. All it cares about is their dimensions.

To line up the 'B's, you would have to compensate for the difference in the space on the left of the 'B' within the box. That depends on a number of things: the font, the size, the character. There is no general way to do this. If you want this case to look right, you'll need to adjust for this case.

Here are the results for 'X' from the same font:

XX

If you adjusted for the 'B's, you would need a quite different adjustment - perhaps none at all - for the 'X's.

So maybe you could just choose titles which begin with 'X'...?

EDIT

Apart from manually specifying appropriate coordinates for nodes containing the two texts, you can move one a little left by saying something like

\node (a) {text 1};
\node (b) [anchor=north east] at ([xshift=-.5em]a.south east) {text 2};

or

\node (b) [anchor=north east, xshift=-.5em] at (a.south east) {text 2};

or use the positioning library

\node (b) [anchor=north east, below left=0pt and .5em of a.south east] {text 2};

or similar.

Thanks to Sean Allred's comment for suggesting this question which focuses on ways to 'nudge' nodes into position.

cfr
  • 198,882
  • +1 :) Might also be good to direct OP on how to 'nudge' things in tikz to provide a solution to the problem :) I would just leave a helpful link as a comment but I'm stuck on mobile – sorry :( – Sean Allred Jul 08 '15 at 03:30
  • @SeanAllred Thanks. The OP seems to have a solution already, though. However, I will see if I can find a link. – cfr Jul 08 '15 at 10:18
  • @SeanAllred If you can recommend a good link, that would be great. I'm finding this information right now only as part of other answers or questions, which adds a lot of unnecessary complexity. In the meantime, I've added a couple of notes on some methods for doing this. – cfr Jul 08 '15 at 10:33
  • 1
    This looks good: http://tex.stackexchange.com/q/198831/17423 – Sean Allred Jul 08 '15 at 13:51
  • @SeanAllred Perfect! Thank you. I tried 'nudge' which got nothing. I tried 'move' which got everything. 'a bit' may have been the magic search term ;). – cfr Jul 08 '15 at 14:06
  • 1
    I can't take all the credit -- Google understood my 'nudge' term :) Much better than SE's own search when scoped to a specific domain. – Sean Allred Jul 08 '15 at 14:12
2

For my solution I have added an additional node with a fixed position. It only works for \normalsize\bfseries text. Code below:

\begin{tikzpicture}[remember picture,overlay,shift={(current page.south west)}]
\node [
  fill=fsorange,
  inner xsep=1em,
  minimum height=1cm,
  text width={\paperheight},
  anchor=north west,
  rotate=90
] at (current page.south west) {\color{white}\bfseries\@date};
\node [
  fill=fsblue,
  inner xsep=1.5cm,
  minimum height=3cm,
  font=\color{white}\bfseries\Huge,
  text width={\paperwidth-1cm},
  anchor=south west
] at (1cm,13cm) {\@titlehead};
\node [
  font=\color{white}\bfseries\normalsize,
  text width={\paperwidth-1cm},
  anchor=south west
] at (2.415cm,13.6cm) {\@subject};
\end{tikzpicture}
  • It will also work only for particular values of \@subject and \@titlehead, and for certain fonts. But case-by-case is how this has to go.... – cfr Jul 08 '15 at 10:15