1

Alright people, I've stumped myself again. It appears (to me at least) that tcolorbox has some outside margins or padding that I don't know how to control.

I use tikz absolute positioning to format the elements of my letters that I need in specific space. For example, this below payment slip need to stay inside the top third of this page (represented by the red filling) because this will be printed on a perforated page.

north east 0,0 offset

\documentclass[letterpaper]{letter}
\usepackage[lmargin=30pt,rmargin=30pt,tmargin=30pt,bmargin=30pt,includefoot]{geometry}
\usepackage{lastpage}
\usepackage{textcomp}
\usepackage{eurosym}
\usepackage{setspace}
\usepackage{helvet}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning} 
\usepackage{qrcode}
\usepackage{pst-barcode}
\graphicspath{{/usr/local/lariat/.template/lib/img/logo/}}




 \pgfdeclarelayer{back}
 \pgfdeclarelayer{front}
 \pgfsetlayers{back,main,front}

\begin{document}

\fontencoding{T1}
\fontfamily{phv}
\fontsize{10}{12}
\selectfont



\begin{tikzpicture}[remember picture,overlay]

    \begin{pgfonlayer}{front}




        \node [xshift=-0pt,yshift=0pt, fill=red, minimum height=264pt, minimum width=614pt,anchor=north east] at (current page.north east) {};

        \node [xshift=-0pt,yshift=-5pt, anchor=north east] at (current page.north east) {
            \begin{tcolorbox}[width=582pt, colframe=darkgray, colback=darkgray, left=-3pt, top=-5pt, coltitle=white, boxsep=2mm, boxcolor=red,boxrule=.1mm, arc=1.5mm, title=\centering \textbf{Payment Authorization}]
                \includegraphics[width=575pt]{paymentform.pdf} 
            \end{tcolorbox}
        };


    \end{pgfonlayer}
\end{tikzpicture}


\end{document}

Additionally, I've noticed that my letter paper is actually 614pt instead of 612pt wide, does anyone know why that is?

Thanks in advance for your assistance you beautiful Latex people.

8
  • 1
    I can not compile your code. It is missing some pdf. – Sigur Feb 16 '19 at 18:10
  • If you use showframe option in geometry you can have a better idea how the page contents are positioned. – Sigur Feb 16 '19 at 18:15
  • Also, maybe you wish lmargin=0pt,rmargin=0pt,paperwidth=614pt. – Sigur Feb 16 '19 at 18:18
  • Here is where my confusion comes in, my tcolorbox is in a tikz node that is absolute positioned to the page.north east. It isn't (or shouldn't be) affected by the page margins. The red node behind my tcolorbox does position to the north east exactly. It's just the tcolorbox that seems to have some kind of padding around it. – James Dunlap Feb 16 '19 at 18:30
  • 2
    TikZ nodes have some inner sep which makes that the inner tcolorbox is not adjusted with node's corner. By the way, if you only use tcolorbox to include an image, why not use a tikz node? – Ignasi Feb 16 '19 at 18:42
2

This could be an alternative construction without tcolorbox

\documentclass[letterpaper]{letter}
\usepackage[lmargin=30pt,rmargin=30pt,tmargin=30pt,bmargin=30pt,includefoot]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning} 

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
\node[fill=red, 
        minimum height=264pt, minimum width=614pt, 
      below left=0pt of current page.north east] (A) {};

\matrix[rounded corners, fill=darkgray,     
    below left=0pt of current page.north east] 
    {
        \node[anchor=center, font=\sffamily\bfseries, color=white]{Payment Authorization};\\
        \node[anchor=center, inner sep=0pt]{\includegraphics[width=575pt, height=200pt]{example-image-A}};\\
    };
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks, Ignasi! I suppose I was using tcolorbox because it makes for some quick and easy formatting across my applications, especially when I'm using different color headers, borders, and body. I suppose I'll need to up by node formatting game. – James Dunlap Feb 16 '19 at 19:51

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.