1

Consider the following example:

\documentclass[twoside, 10pt]{book}
\usepackage[
    paperwidth=6in,
    paperheight=9in,
    tmargin=0.75in,
    bmargin=0.75in,
    inner=0.75in,
    outer=0.75in
]{geometry}
\usepackage{calc}
\usepackage{tikz}
\usepackage{etoolbox}
\usepackage{transparent}
\usepackage{tikzpagenodes}
\usepackage[table]{xcolor}
\usetikzlibrary{calc}
\usetikzlibrary{fadings}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{matrix}
\pagestyle{empty}

\begin{document}

\tikz[remember picture, overlay]{
    \node[
        circle,
        fill = black,
        font = \sffamily\fontsize{24}{24}\bf\selectfont\color{white},
        anchor = west,
        minimum size = 1.5cm,
        outer sep = 0pt
    ] at (current page text area.center) (numb) {I};
    \node[
        anchor = east,
        inner sep = 0pt,
        outer sep = 0pt,
        font = \sffamily\fontsize{48}{48}\selectfont
    ] at ($(numb.west) + (-0.5cm, 0cm)$) {
        This is part 
    };
}

\end{document}

which gives the following output:

Image example

Currently the west of the first node is centered on the page. Instead of that, how to horizontally center the center of the two nodes (as if it were only one big node) with the center of the page text area? (I am searching for a command inside the tikz environment, not a global \begin{center} \end{center} to wrap the tikz figure.) In other words, the end result should be to have "This is part I" horizontally centered on the text area of the page.

  • 1
    Note that you get an option clash error from xcolor because tikz loads xcolor. Move \usepackage[table]{xcolor} to before \usepackage{tikz}. – Torbjørn T. Oct 13 '17 at 12:03
2

You could use a \matrix:

\documentclass[twoside, 10pt]{book}
\usepackage[
    paperwidth=6in,
    paperheight=9in,
    tmargin=0.75in,
    bmargin=0.75in,
    inner=0.75in,
    outer=0.75in
]{geometry}
\usepackage{calc}
\usepackage[table]{xcolor}

\usepackage{etoolbox}
\usepackage{transparent}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usetikzlibrary{fadings}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{matrix}
\pagestyle{empty}

\begin{document}

\tikz[remember picture, overlay]{
  \matrix [column sep=5mm] at (current page text area.center) {
    \node[
        anchor = east,
        inner sep = 0pt,
        outer sep = 0pt,
        font = \sffamily\fontsize{48}{48}\selectfont
    ] {This is part};
 &
    \node[
        circle,
        fill = black,
        font = \sffamily\fontsize{24}{24}\bf\selectfont\color{white},
        anchor = west,
        minimum size = 1.5cm,
        outer sep = 0pt
    ]  (numb) {I};
\\
};
}

\end{document}

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.