1

I trying to create a cover page using tikz and I would like to position a tabular element in a colored tikz rectangle both horizontally left justified and vertically centered.

In the attached example the tubular is being centered horizontally, as well at vertically. How do I left justify the tabular, whilst keeping the vertical centering in the rect node?

Thanks

Stuart

    \documentclass[a4paper,12pt]{article}
    \usepackage{tikz}

    \begin{document}
        \thispagestyle{empty}
        \begin{tikzpicture}[remember picture,overlay]
                \node (rect) [shape=rectangle, fill=red, minimum height=40mm, minimum width=\paperwidth, anchor=south west] at (current page.south west) {};
                \node [anchor=west] at (rect.center) {
                    \begin{tabular}{|l|r|}
                     A & B \\
                    \end{tabular}
                };
        \end{tikzpicture}
    \end{document}
  • Left justified means flushed to the right margin or flushed to the right edge of the paper? – Gonzalo Medina Sep 28 '15 at 23:04
1

Since it's not clear from the question whether "left justified" means flushed to the right margin or flushed to the right edge of the paper, I provide both options; locate the node at (rect.east) for the formaer or at (current page text area.east|-rect.east) (requires the tikzpagenodes package) for the latter. The showframe package is just to provide a visual guide to the page layout:

\documentclass[a4paper,12pt]{article}
    \usepackage{tikzpagenodes}
\usepackage{showframe}
    \begin{document}
        \thispagestyle{empty}
        \begin{tikzpicture}[remember picture,overlay]
                \node (rect) [shape=rectangle, fill=red, minimum height=40mm, minimum width=\paperwidth, anchor=south west] at (current page.south west) {};
                \node [anchor=east,inner sep=0pt] at (rect.east) {%
                    \begin{tabular}{|l|r|}
                     A & B \\
                    \end{tabular}%
                };
                \node [anchor=east,inner sep=0pt] at (current page text area.east|-rect.east) {%
                    \begin{tabular}{|l|r|}
                     A & B \\
                    \end{tabular}%
                };
        \end{tikzpicture}
    \end{document}

enter image description here

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.