1

I am working on a project that will require intense timeline fields and all to keep track of stuff so I am trying to make it all easier by making it automatic. I have made a lot of progress in it however, there is an issue I cannot resolve so I am asking for help. I have created this document that shows it. I apologise for the formatting, I am not familiar with how to format this properly on tex.stackexchange.

\documentclass{article}
\usepackage{calc}
\usepackage{tikz}
\usepackage{xstring}
\usepackage{etoolbox}

\newcommand{\drawbubble}[3]{
    \renewcommand{\rowlng}{\arabic{rowlng}}
    \renewcommand{\rowh}{\arabic{nrrows}}
    \node at (#1-0.9,#2) {#3 };
    %\StrLen{#3}[\lenstr]
    \draw [rounded corners, thick, black] (#1-\rowlng/11-0.08,#2) -- (#1-\value{rowlng}/11-0.08,#2-0.6) -- (#1+\rowlng/11+0.08,#2-0.6) -- (#1+\rowlng/11+0.08,#2+0.6) -- (#1-\rowlng/11-0.08,#2+0.6) -- (#1-\rowlng/11-0.08,#2);}

%\newcommand{\drawbubble}[3]{\StrLen{#3}[\lenstr] 
%\draw [rounded corners, thick, black] (#1-\lenstr/11-0.08,#2) -- (#1-\lenstr/11-0.08,#2-0.6) -- (#1+\lenstr/11+0.08,#2-0.6) -- (#1+\lenstr/11+0.08,#2+0.6) -- (#1-\lenstr/11-0.08,#2+0.6) -- (#1-\lenstr/11-0.08,#2);
%\node at (#1,#2) {#3};}

\newcommand{\tmtxt}{}
\newcommand{\rowlng}{0}
\newcommand{\rowh}{0}
\newcounter{nrrows}
\newcounter{rowlng}
\newcounter{tstlng}
\newcommand{\addtxt}[2]{
    \appto#1{#2}
}

\makeatletter % we need to use kernel commands
\newcommand{\starttimetext}{%
    \renewcommand{\tmtxt}{\begin{tabular}[c]{@{}c@{}}}
        \setcounter{nrrows}{0}
        \setcounter{rowlng}{0}
        \setcounter{tstlng}{0}
        \@timetexti
    }
    \newcommand\@timetexti{\@ifnextchar\stoptimetext{\@timetextend}{\@timetextii}}

    \newcommand\@timetextii[1]{%
        \@timetextiii{#1}
        \stepcounter{nrrows}
        \@timetexti % restart the recursion
    }
    \newcommand\@timetextiii[1]{%
        \StrLen{#1}[\testlen]
        \setcounter{tstlng}{\testlen}
        \ifnum\therowlng<\thetstlng
        \setcounter{rowlng}{\value{tstlng}}
        \fi
        \addtxt{\tmtxt}{#1\\}}
    \newcommand\@timetextend[1]{% The argument is \stopimages
        \addtxt{\tmtxt}{\end{tabular}}
    %\arabic{rowlng}:\arabic{nrrows}
    \tmtxt
}
\makeatother

\begin{document}
\begin{tikzpicture}
\drawbubble{0}{4.2}{\starttimetext
    {test}{altso}
    \stoptimetext}
\drawbubble{0}{1.2}{\starttimetext
    {vaginas}
    \stoptimetext}
\drawbubble{3}{4.2}{\starttimetext
    {testingtonomatic}
    \stoptimetext}
\end{tikzpicture}
\end{document}

The first one, with two lines, pushes outside the bounds while the latter ones do not with only one row. When I change them around the same thing happens and others. I am trying to make it such that it counts lines and width and makes the area around compensate.

What am I doing that causes it to start shifting the moment more rows are added? The timetext part is to get the rows working which I could not get otherwise.

  • Code blocks are indented by four spaces and, which can be done by selecting the code block and pressing the symbol with the curly braces among the edit toolbar buttons. – Heiko Oberdiek Jul 5 '16 at 17:39
  • I am sorry but what do you mean with it? – Zelos Malum Jul 5 '16 at 17:41
  • I am referring to the fourth sentence of the question. – Heiko Oberdiek Jul 5 '16 at 17:42
1

I'm not certain what result you're trying to achieve. Do you want something like this?

possibility

\documentclass{article}
\usepackage{calc}
\usepackage{tikz}
\usepackage{xstring}
\usepackage{etoolbox}

\newcommand{\drawbubble}[3]{%
%   \renewcommand{\rowlng}{\arabic{rowlng}}%
%   \renewcommand{\rowh}{\arabic{nrrows}}%
  \node [draw, rounded corners, thick, black] at (#1-0.9,#2) {#3 };
  %\StrLen{#3}[\lenstr]
%   \draw [rounded corners, thick,  blue] (#1-\value{rowlng}/11-0.08,#2) -- (#1-\value{rowlng}/11-0.08,#2-0.6) -- (#1+\value{rowlng}/11+0.08,#2-0.6) -- (#1+\value{rowlng}/11+0.08,#2+0.6) -- (#1-\value{rowlng}/11-0.08,#2+0.6) -- (#1-\value{rowlng}/11-0.08,#2);
}

%\newcommand{\drawbubble}[3]{\StrLen{#3}[\lenstr]
%\draw [rounded corners, thick, black] (#1-\lenstr/11-0.08,#2) -- (#1-\lenstr/11-0.08,#2-0.6) -- (#1+\lenstr/11+0.08,#2-0.6) -- (#1+\lenstr/11+0.08,#2+0.6) -- (#1-\lenstr/11-0.08,#2+0.6) -- (#1-\lenstr/11-0.08,#2);
%\node at (#1,#2) {#3};}

\newcommand{\tmtxt}{}
% \newcommand{\rowlng}{0}
% \newcommand{\rowh}{0}
\newcounter{nrrows}
\newcounter{rowlng}
\newcounter{tstlng}
\newcommand{\addtxt}[2]{%
  \appto#1{#2}%
}

\makeatletter % we need to use kernel commands
\newcommand{\starttimetext}{%
\renewcommand{\tmtxt}{%
  \begin{tabular}[c]{@{}c@{}}%
  }%
  \setcounter{nrrows}{0}%
  \setcounter{rowlng}{0}%
  \setcounter{tstlng}{0}%
  \@timetexti
}
\newcommand\@timetexti{\@ifnextchar\stoptimetext{\@timetextend}{\@timetextii}}

\newcommand\@timetextii[1]{%
  \@timetextiii{#1}%
  \stepcounter{nrrows}%
  \@timetexti % restart the recursion
}
\newcommand\@timetextiii[1]{%
  \StrLen{#1}[\testlen]%
  \setcounter{tstlng}{\testlen}%
  \ifnum\therowlng<\thetstlng
    \setcounter{rowlng}{\value{tstlng}}%
  \fi
  \addtxt{\tmtxt}{#1\\}%
}
\newcommand\@timetextend[1]{% The argument is \stopimages
  \addtxt{\tmtxt}{\end{tabular}}%
  %\arabic{rowlng}:\arabic{nrrows}
  \tmtxt
}
\makeatother

\begin{document}
\begin{tikzpicture}
  \drawbubble{0}{4.2}{\starttimetext
    {test}{altso}
    \stoptimetext}
  \drawbubble{0}{1.2}{\starttimetext
    {vaginas}
    \stoptimetext}
  \drawbubble{3}{4.2}{\starttimetext
    {testingtonomatic}
    \stoptimetext}
\end{tikzpicture}
\end{document}

Note that I've commented out most (hopefully all) of what I took to be spurious spaces. If you wanted those spaces, you'll need to put them back.

|improve this answer|||||
  • Exactly! Thank you! I will be analysing the code to see what it all means! Thank you once again! – Zelos Malum Jul 5 '16 at 19:21

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.