3

I mean, if I use e.g. \blockwidth for setting a width of tikzfigure environment, I get a undefined control sequence error. In that case one workaround is using \linewidth, but I need to subtract the separation distance from the edge of the box, and I could not access that separation as well.

Obviously, when one defines custom styles for elements, dimensions are well defined, as one can read in the documentation.

But, is there any way to access them inside the body of the poster?

I think it is difficult and not relevant in this case to give a MWE. Nevertheless, I give it.

\documentclass{tikzposter}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\title{Title} \institute{Inst}
\author{Auth} \titlegraphic{Logo}
\usetheme{Basic}
\begin{document}
 \maketitle
 \block{BlocktitleA}{Blocktext}
 \begin{columns}
  \column{0.3}
  \block{BlocktitleB}{
   \newlength{\figw}
   \setlength{\figw}{\blockwidth}
   \begin{tikzpicture}
   \pgfplotsset{
    height=0.5*\figw,
    width=0.5*\figw,
   }
   \begin{axis}[
                xmin=1.5,
                xmax=5
               ]
    \addplot[
             solid,
             line width=0.8mm,
             samples=100,
             domain=1.5:5,
             restrict y to domain=0.6:2.2
            ] {0.7+(2.22/x)};
   \end{axis}
  \end{tikzpicture}
  }
  \column{0.7}
  \block{BlocktitleC}{Blocktext}
  \note{Notetext}
 \end{columns}
\end{document}

This gives an undefined control sequence error and a zero length warning.

Torbjørn T.
  • 206,688
  • 1
    Hi, welcome. Always appreciated if you can add a minimal working example to a question. For some questions it is entirely necessary to be able to answer, and in most other cases it is nice to not have to make up a complete example for testing. – Torbjørn T. Oct 31 '17 at 16:25
  • A MWE is always helpful! – samcarter_is_at_topanswers.xyz Oct 31 '17 at 17:28
  • With regard to a pgfplots axis, the problem is that when you set the width to X, pgfplots sets the width of the axis box alone to X-45pt, and then it adds ticklabels/axis labels afterwards. The 45pt is fixed, pgfplots doesn't measure the width of ticklabels etc. In your case, the labels are wider than 45pt because of the font size, so the total width of the diagram becomes wider than the specified size. This is a general problem of pgfplots. But going back to your question, I think you can access those lengths, will likely add an answer in a bit. – Torbjørn T. Oct 31 '17 at 18:10
  • Thanks @TorbjørnT, for that remark. I am also checking the tikzposter.cls. I never used before xkeyval package, but all the definitions of lengths are managed with it. Then I think every time some element of the poster is called, the keys are set with the information given by the style and user input. Then the problem reduces to how to access the keys of each element instance. – elessartelkontar Oct 31 '17 at 18:27
  • Look at the definition of the \block macro, note that for example that if you're in a \column, then the \TP@blockbodywidth is set to \colwidth. And later, the text in the block is put in a \parbox of width \TP@blockbodywidth-2\TP@blockbodyinnersep-\TP@blockbodyoffsetx. (By the way, the class defines a tikzfigure environment, but the width of that cannot be set -- it will be \linewidth -- and you're not using it in your example.) I wont have time to write an answer right now, maybe later if I figure things out. But don't hesitate to add an answer yourself. – Torbjørn T. Oct 31 '17 at 18:33
  • @TorbjørnT do not worry, thanks for the guidance. I will try to figure it out and give an answer. If that is not possible, I will be glad to see yours. – elessartelkontar Oct 31 '17 at 18:39

2 Answers2

1

If you use \linewidth inside the block the separation towards the boarders are already subtracted, see the width of the rule in the following example:

\documentclass{tikzposter}
\usetheme{Basic}

\usepackage{lipsum}

\begin{document}
 \block{BlocktitleA}{Blocktext}
 \begin{columns}
  \column{0.3}
  \block{BlocktitleB}{
   \newlength{\figw}
   \setlength{\figw}{\linewidth}
     \rule{\figw}{2pt}

     \lipsum
  }
 \end{columns}
\end{document}

enter image description here


The better question is why your pgf plot is wider than the linewidth. tikz automatically places some padding around your plot, which you can disable with inner sep=0pt.

However I would make the plot a bit larger then \linewidth (about 1 %) to align the right axis with the boarder of the surrounding text, even if the 5 on the x axis now slightly protrudes into the margin.

\documentclass{tikzposter}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\usetheme{Basic}
\usepackage{lipsum}
\usepackage{printlen}
\usetikzlibrary{backgrounds}
\begin{document}
 \block{BlocktitleA}{Blocktext}
 \begin{columns}
  \column{0.3}
  \block{BlocktitleB}{

    \lipsum[2]

   \begin{tikzpicture}[inner sep=0pt]%
       \begin{axis}[%
                    width=1.01\linewidth,
                    xmin=1.5,%
                    xmax=5%,
                   ]%
        \addplot[%
                 solid,%
                 line width=0.8mm,%
                 samples=100,%
                 domain=1.5:5,%
                 restrict y to domain=0.6:2.2%
                ] {0.7+(2.22/x)};%
       \end{axis}%
  \end{tikzpicture}%
  }
 \end{columns}
\end{document}

enter image description here

  • I think that is not the case when you use it with a tikzfigure, the box of the plot, using \linewidth, is directly over block edge. Notwithstanding, that is not the answer to the question, since the question, as clearly stated, was if there is some way to access, from within the document, the lengths defined by the class, such \blockwidth and the separator. – elessartelkontar Oct 31 '17 at 17:39
  • @elessartelkontar That's a problem of the pgf plot and not with the width. \linewidth is the length you asked for in the question. – samcarter_is_at_topanswers.xyz Oct 31 '17 at 17:46
  • and how I get the inner block width. And \blockwidth or \linewidth was only an example – elessartelkontar Oct 31 '17 at 17:51
0

When in a columns environment, the total width of a \block is \colwidth. The width of the text block is \linewidth. Those two are always available I believe.

The code below demonstrates how to define additional macros to access the dimensions that the class defines. This is not a definitive list of course, but I suppose it should cover most cases.

output of code

\documentclass[a1paper]{tikzposter}
\usepackage{pgfplots,array}
\usetikzlibrary{calc,arrows.meta}
\title{Title} \institute{Inst}
\author{Auth} \titlegraphic{Logo}
\usetheme{Basic}

% define macros without @
\makeatletter
\newcommand{\blockwidth}{\TP@blockbodywidth}
\newcommand{\blockinnersep}{\TP@blockbodyinnersep}
\newcommand{\innerblockwidth}{\TP@innerblockbodywidth}
\newcommand{\innerblockinnersep}{\TP@innerblockbodyinnersep}
\makeatother

\newcommand\printtable{%
\begin{tabular}{@{}>{\ttfamily\textbackslash}ll}
\multicolumn{2}{l}{Existing macros:} \\
colwidth            & \the\colwidth \\
linewidth           & \the\linewidth \\[10pt]
\multicolumn{2}{l}{New macros:} \\
blockwidth          & \the\blockwidth \\
blockinnersep       & \the\blockinnersep \\
innerblockwidth & \the\innerblockwidth \\
innerblockinnersep  & \the\innerblockinnersep
\end{tabular}

\bigskip

% demonstrates extent of text block
X\dotfill X}


\newcommand\printdimensions{%
% the background and frame of a block is drawn by a node named blockbody
% use that to draw some lines
\draw
let
\p1=(blockbody.south west),\p2=(blockbody.south east),\n1={scalar(\x2-\x1)}
in
[red,Bar-Bar,ultra thick] (\x1,\y1-4cm) coordinate (a) -- (\x2,\y2-4cm) coordinate (b)
node[midway,above] {$\mathtt{blockwidth} \approx \n1\,\mathrm{pt}$};

\draw [dashed,red] (blockbody.west) -- ([yshift=-1cm]a);
\draw [dashed,red] (blockbody.east) -- ([yshift=-1cm]b);

\draw
let
\p1=(blockbody.south west),\p2=(blockbody.south east),\n1={scalar(\x2-\x1-2*\blockinnersep)}
in
[blue,Bar-Bar,ultra thick] (\x1+\blockinnersep,\y2-2cm) coordinate (a) -- (\x2-\blockinnersep,\y2-2cm) coordinate (b)
node[midway,above] {$\mathtt{linewidth} \approx \n1\,\mathrm{pt}$};

\draw [dashed,blue] ([yshift=6cm]a) -- ([yshift=-1cm]a);
\draw [dashed,blue] ([yshift=6cm]b) -- ([yshift=-1cm]b);
}

\begin{document}
\maketitle

\begin{columns}
\column{0.4}

  \block{BlocktitleB}{\printtable}
  \printdimensions

\column{0.6}

  \block[bodyinnersep=50pt]{BlocktitleC}{\printtable}
  \printdimensions

\note{Notetext}
\end{columns}


\block[bodyoffsety=-4cm,titleoffsety=-5cm]{BlocktitleA}{
\printtable
\innerblock{Inner}{\printtable}
}
\printdimensions

\end{document}
Torbjørn T.
  • 206,688