Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am currently preparing a poster for a conference and decided to use 'beamerposter' for that purpose.

As I don't really like the standard templates I decided to go after a design similar to this one: http://ai.stanford.edu/~tadayuki/poster/poster-sample.pdf

(Unfortunately, I cannot use that template directly, as I ran into some problems when using my own TikZ figures.)

This is a short example of my code:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[orientation=portrait,size=a0,scale=1.4,debug]{beamerposter}
\usepackage{tikz}
\usepackage[english]{babel}
\usepackage{xparse}
\usepackage{blindtext}

\usetikzlibrary{positioning}
\xdefinecolor{topcolor}{rgb}{0.2, 0.4, 0.6}
\xdefinecolor{bottomcolor}{rgb}{1, 0.99, 0.82}
\xdefinecolor{blocktitleboxcolor}{rgb}{0.15, 0.30, 0.60}
\xdefinecolor{blocktitletextcolor}{rgb}{1.00, 1.00, 1.00}
\beamertemplateshadingbackground{bottomcolor}{topcolor}

% The interesting stuff starts here
\newsavebox\blockbox
\NewDocumentEnvironment{myblock}{+m}{%
  \vskip 0.5em
  \begin{lrbox}{\blockbox}%
    \begin{minipage}{1.00\textwidth}
}{
    \end{minipage}
  \end{lrbox}
  \begin{tikzpicture}[node distance=-0.5em]
  \node[
    fill=white,
    draw=black,
    line width=4pt,
    inner sep=1cm,
    rounded corners=1cm,
    text width=\textwidth-2cm, % This does not work as expected
    outer sep=0pt
  ](textnode){\usebox\blockbox};
  \node[anchor=north,
        above=of textnode,
        draw=black,
        fill=blocktitleboxcolor,
        text=blocktitletextcolor,
        rounded corners=.5cm,
        line width=4pt,
        inner xsep=0.8cm,
        inner ysep=0.4cm] {\textit{\textsf{\textbf{#1}}}};
  \end{tikzpicture}
}

\begin{document}
\begin{frame}
  \begin{columns}[T]
    \begin{column}{0.40\textwidth}
      \rule{\textwidth}{0.5cm}
      \begin{myblock}{Foo}
        \blindtext
      \end{myblock}
    \end{column}
    \begin{column}{0.40\textwidth}
      \rule{\textwidth}{0.5cm}
      \begin{myblock}{Foo}
        \blindtext
      \end{myblock}
    \end{column}
  \end{columns}
\end{frame}
\end{document}

However, I would like to have the TikZ node to have a total width of \textwidth (indicated by the horizontal rules).

Unfortunately, I cannot use the 'text width' property on the node. The problem seems to be that the text that is stored in \blockbox has a width of \textwidth.

Is there a way to reset the width of the box?

As I am not very proficient with the TeX internals, there might well be a better way to achieve what I want, so please feel free to suggest a better approach...

share|improve this question

2 Answers 2

up vote 4 down vote accepted

enter image description here

You need to allow for the frame padding when you set the box:

\usepackage{calc}

Then you can go:

  \begin{lrbox}{\blockbox}%
    \begin{minipage}{\textwidth - 2cm}
share|improve this answer
    
Wow, that was quick! :-) Thank you very much! –  Aton Jun 8 '12 at 19:37
    
Another TikZ upvote. One step closer to the gold badge! –  Werner Jun 8 '12 at 20:37

TikZ reads the node content as box, not as macro argument, therefore you can replace \node {..} with \node \bgroup .. \egroup and put both parts in the begin and end parts of you environment. This removes the need for storing the content into a box and your related issue.

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[orientation=portrait,size=a0,scale=1.4,debug]{beamerposter}
\usepackage{tikz}
\usepackage[english]{babel}
\usepackage{xparse}
\usepackage{blindtext}

\usetikzlibrary{positioning}
\xdefinecolor{topcolor}{rgb}{0.2, 0.4, 0.6}
\xdefinecolor{bottomcolor}{rgb}{1, 0.99, 0.82}
\xdefinecolor{blocktitleboxcolor}{rgb}{0.15, 0.30, 0.60}
\xdefinecolor{blocktitletextcolor}{rgb}{1.00, 1.00, 1.00}
\beamertemplateshadingbackground{bottomcolor}{topcolor}

% The interesting stuff starts here
\NewDocumentEnvironment{myblock}{+m}{%
  \vskip 0.5em
  \begin{tikzpicture}[node distance=-0.5em]
  \node[
    fill=white,
    draw=black,
    line width=4pt,
    inner sep=1cm,
    rounded corners=1cm,
    text width=\textwidth-2cm, % This does work as expected now
    outer sep=0pt
  ](textnode)
  \bgroup
}{%
  \egroup;
  \node[anchor=north,
        above=of textnode,
        draw=black,
        fill=blocktitleboxcolor,
        text=blocktitletextcolor,
        rounded corners=.5cm,
        line width=4pt,
        inner xsep=0.8cm,
        inner ysep=0.4cm] {\textit{\textsf{\textbf{#1}}}};
  \end{tikzpicture}
}

\begin{document}
\begin{frame}
  \begin{columns}[T]
    \begin{column}{0.40\textwidth}
      \rule{\textwidth}{0.5cm}
      \begin{myblock}{Foo}
        \blindtext
      \end{myblock}
    \end{column}
    \begin{column}{0.40\textwidth}
      \rule{\textwidth}{0.5cm}
      \begin{myblock}{Foo}
        \blindtext
      \end{myblock}
    \end{column}
  \end{columns}
\end{frame}
\end{document}
share|improve this answer
    
Thanks for your answer! Unfortunately I do not know TeX well enough in order to assess both solutions. Would you mind elaborating on what are the pros and cons of your approaches? (If there are any...) –  Aton Jun 8 '12 at 19:56
    
@Aton: In this approach you can wrap the node directly around the content without the requirement of boxing it first. This is more efficient and also allows you to use all TikZ styles directly on the content, i.e. text width now works as expected. –  Martin Scharrer Jun 8 '12 at 20:18
    
I believe one disadvantage to that approach is that you have to be careful if you want to include TikZ pictures in the node as they will inherit its properties. The approach by David Carlisle does not seem to have this problem. I can even cite you on this: tex.stackexchange.com/questions/51193/… :-) –  Aton Jun 8 '12 at 22:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.