8

EDIT:

\documentclass[10pt]{article}
\usepackage{geometry}
\usepackage[skins]{tcolorbox}
\usepackage{fancyhdr}
\renewcommand{\footrule}{\hbox to\headwidth{\color{blue}\leaders\hrule height \footrulewidth\hfill}}
\fancypagestyle{document}{
\renewcommand{\footrulewidth}{2pt}
\rfoot{  \raisebox{\dimexpr(-\height+\ht\strutbox-\dp\strutbox)/2}{%
    \begin{tcolorbox}[nobeforeafter,
  width=.3\linewidth,
  frame hidden,boxrule=0pt,
  colback=white,
  freelance,
  arc=0pt,
  outer arc=0pt,
  boxrule=0pt,
  frame code={
    \draw[blue,line width=2.5pt]  
      ([xshift=-1.25pt]frame.north west) -- ([xshift=-1.25pt]frame.south west);
      }
]\hfill Naar Index~$\rightarrow$ \end{tcolorbox}}}
\lfoot{\raisebox{\dimexpr(-\height+\ht\strutbox-\dp\strutbox)/2}{%
    \begin{tcolorbox}[nobeforeafter,
  width=.3\linewidth,
  frame hidden,boxrule=0pt,
  colback=white,
  freelance,
  arc=0pt,
  outer arc=0pt,
  boxrule=0pt,
  frame code={
    \draw[blue,line width=2.5pt]  
      ([xshift=1.25pt]frame.north east) -- ([xshift=1.25pt]frame.south east);
      }
]$\leftarrow$~Inhoudsopgave\hfill\end{tcolorbox}}}
}
\begin{document}
\thispagestyle{document}
.
\end{document}

I still have the same problem. The code above outlines the issue: the bars don't align.

EDIT: the bars didn't align because I missed a \strut before the actual text.

http://i.imgur.com/D0uaDdF.png


When I use a tcolorbox with nobeforeafter inside my footer, the rest of the footer jumps downward. How to stop this from happening?

\documentclass[10pt]{article}
\usepackage{fancyhdr}
\usepackage{tcolorbox}
\fancypagestyle{plain}{
\renewcommand{\footrulewidth}{1pt}
\rfoot{\begin{tcolorbox}[nobeforeafter,width=.3\linewidth]text\end{tcolorbox}}
\lfoot{text}
}
\begin{document}
\thispagestyle{plain}
text
\end{document}

http://i.imgur.com/whJJHqg.png

1
  • You can use the option baseline=5mm for instance. You should first calculate the height of your box with the text.
    – pluton
    May 18, 2014 at 15:49

2 Answers 2

6

No need to guess: leave the measurements to TeX.

If you want the text in the tcolorbox to be aligned to the other text in the footer, then

\documentclass[10pt]{article}
\usepackage{fancyhdr}
\usepackage{tcolorbox}
\fancypagestyle{plain}{%
  \renewcommand{\footrulewidth}{1pt}%
  \fancyfoot[R]{\myfancyfoot{teyt}}%
  \fancyfoot[L]{text}%
}

\newcommand{\myfancyfoot}[1]{%
  \raisebox{\dimexpr(-\height+\ht\strutbox-\dp\strutbox)/2}{%
    \begin{tcolorbox}[nobeforeafter,width=.3\linewidth]
    \strut #1
    \end{tcolorbox}}%
}

\begin{document}
\thispagestyle{plain}
text
\end{document}

enter image description here

If, instead, you want the top line of the tcolorbox to be level with the height of the other elements, then

\documentclass[10pt]{article}
\usepackage{fancyhdr}
\usepackage{tcolorbox}
\fancypagestyle{plain}{%
  \renewcommand{\footrulewidth}{1pt}%
  \fancyfoot[R]{\myfancyfoot{teyt}}%
  \fancyfoot[L]{text}%
}

\newcommand{\myfancyfoot}[1]{%
  \raisebox{\dimexpr -\height+\ht\strutbox}{%
    \begin{tcolorbox}[nobeforeafter,width=.3\linewidth]
    #1
    \end{tcolorbox}}%
}

\begin{document}
\thispagestyle{plain}
text
\end{document}

enter image description here

6

You can raise the box by the amount needed to put the other text where you want to:

\documentclass[10pt]{article}
\usepackage{fancyhdr}
\usepackage{tcolorbox}
\fancypagestyle{plain}{
\renewcommand{\footrulewidth}{1pt}
\rfoot{\begin{tcolorbox}[tcbox raise=-.7cm,nobeforeafter,width=.3\linewidth]text\end{tcolorbox}}
\lfoot{text}
}
\begin{document}
\thispagestyle{plain}
text
\end{document}

enter image description here

Change the tcbox raise value as needed.

5
  • This almost did the trick. See my edit in the OP.
    – 1010011010
    May 18, 2014 at 16:07
  • @1010011010 See if egreg answer solves your problem, otherwise you should post a more accurate mwe to work with.
    – d-cmst
    May 18, 2014 at 16:14
  • I'll post the full thing.
    – 1010011010
    May 18, 2014 at 16:15
  • 1
    Second solution of the post down below solved it, but I had to manually adjust the bounding box. See i.imgur.com/xYnvnFP.png
    – 1010011010
    May 18, 2014 at 16:23
  • Oh well, now the post is "up above", but that's still fine :)
    – d-cmst
    May 18, 2014 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .