3

Based on Toggle bullet point in vertical timeline I want to customize the appearance of the bullet points in a tabular based setting. I want to use, e.g. \faArrowCircleLeft from fontawesome package. The glyph should appear above the vertical line. However, since the glyph is transparent, I wanted to put a circle in the background using tikz. I am not able to align the background accordingly, see the following example, where I used green color instead of white for the purpose of demonstration.

enter image description here

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{etoolbox}
\usepackage{xtab}
\usepackage{array}
\usepackage{fontawesome5}
\usepackage{graphicx}
\usepackage{tikz}
\definecolor{accentcolor}{RGB}{ 250, 150, 10 }
\definecolor{accentcolortwo}{RGB}{ 50, 150, 10 }

\newbool{time_bullet}
\setbool{time_bullet}{true}

\renewcommand\arraystretch{2.8}

\newcommand{\foo}{\color{accentcolor!80}\vrule width 1pt 
    \makebox[0pt][c]{%
        \ifbool{time_bullet}{%
        \parbox{6pt}{\color{\accentcolor}{\tikz{
    \node[circle,fill=green,text width=0pt, xshift=-0pt, minimum width=0pt,inner sep=0pt, outer sep=0pt] {\faArrowCircleLeft} ;}
    }}\setbool{time_bullet}{false}}
{\setbool{time_bullet}{true}}
}\hskip-0.0pt\hspace{\labelsep}\ifbool{time_bullet}{\global\setbool{time_bullet}{false}}{\global\setbool{time_bullet}{true}}}

\newcolumntype{F}{<{\hskip 0pt} !{\foo} >{\raggedright\arraybackslash}p{3cm}}

\begin{document}

\begin{tabular}{lF}
     1 & Test\\
    2 & Test \\
    3 & Test
\end{tabular}

\end{document}

1 Answer 1

2
+50

I rewrite the solution in LaTeX3, which supports stride values other than 2.

enter image description here

Update

enter image description here

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{etoolbox}
\usepackage{xtab}
\usepackage{array}
\usepackage{fontawesome5}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{adjustbox}
\usepackage{expl3}

\definecolor{accentcolor}{RGB}{ 250, 150, 10 }
\definecolor{accentcolortwo}{RGB}{ 50, 150, 10 }

\ExplSyntaxOn

\int_new:N \g_bullet_index_int
\dim_new:N \g_bullet_rule_width_dim
% vertical rule width
\dim_gset:Nn \g_bullet_rule_width_dim {1pt}

% bullet stride
\int_new:N \g_bullet_stride_int

% get the width of the arrow
\dim_new:N \g_arrow_width_dim
\hcoffin_set:Nn \l_tmpa_coffin {\faArrowCircleLeft}
\dim_gset:Nn \g_arrow_width_dim {\coffin_wd:N \l_tmpa_coffin}

% the value is used to compensate for bigger circle
% at the bottom
\fp_new:N \g_arrow_width_factor_fp
\fp_gset:Nn \g_arrow_width_factor_fp {0.90}

% compute new arrow width for background circle
\dim_new:N \g__arrow_width_dim
\dim_gset:Nn \g__arrow_width_dim {\fp_use:N\g_arrow_width_factor_fp \g_arrow_width_dim}


% compute lap value
\dim_new:N \g_bullet_lap_dim
\dim_gset:Nn \g_bullet_lap_dim {
  0.5\g_bullet_rule_width_dim + 0.5\g_arrow_width_dim
}

\newcommand*{\resetbullet}{
  \int_gset:Nn \g_bullet_index_int {0}
}

\newcommand*{\setbulletstride}[1]{
  \int_gset:Nn \g_bullet_stride_int {#1}
}

\newcommand{\dobullet}{
  % draw verticle rule
  \color{accentcolor!80}\vrule width \g_bullet_rule_width_dim
  % draw bullet at correct position
  \int_compare:nNnT { \int_mod:nn {\g_bullet_index_int} {\g_bullet_stride_int} } = {0} {
    \color{accentcolor}
    \adjustbox{left=0cm,
      lap=-\g_bullet_lap_dim}{
      \tikz{
        \node[circle, fill=accentcolor!80,
              minimum~width=\g_arrow_width_dim,
              inner~sep=0pt,
              outer~sep=0pt]
              {};
        \node[circle,fill=green,
              % manually tune the width of arrow so that their size fit
              minimum~width=\g__arrow_width_dim,
              inner~sep=0pt, 
              outer~sep=0pt] 
              {};
        \node[inner~sep=0pt,
              outer~sep=0pt]
              {\faArrowCircleLeft};
       }
     }
  }
  \hskip-0.0pt \hspace{\labelsep}
  % increment counter
  \int_gincr:N \g_bullet_index_int
}

\ExplSyntaxOff

\newcolumntype{F}{<{\hskip 0pt} !{\dobullet} >{\raggedright\arraybackslash}p{3cm}}


\begin{document}


\renewcommand\arraystretch{1.2}

% set stride to 2
\setbulletstride{2}
% reset bullet counter before new tabular
\resetbullet

\begin{tabular}{lF}
     1 & Test\\
    2 & Test \\
    3 & Test
\end{tabular}

\vspace{1em}

% set stride to 3
\setbulletstride{3}
% reset bullet counter before new tabular
\resetbullet

\begin{tabular}{lF}
     1 & Test\\
    2 & Test \\
    3 & Test \\
    4 & Test
\end{tabular}

\end{document}
6
  • you would be better to add a module name to the variable names, e.g. \g_dba_bullet_index_int and \g_dba_arrow_width_dim Commented Oct 19, 2020 at 7:13
  • This looks quite promising. The bullets do center with respect to the right border of the vrule though. And thus it is not centered.
    – dba
    Commented Oct 20, 2020 at 9:27
  • And also, there is a small margin in green around the circle. Is there any way of decreasing the radius of that circle?
    – dba
    Commented Oct 20, 2020 at 9:32
  • @dba Please refer to the newer version.
    – Alan Xiang
    Commented Oct 20, 2020 at 14:30
  • 1
    @dba I don't have a definite answer. My guess is tikz failed to align node text and shape correctly.
    – Alan Xiang
    Commented Oct 21, 2020 at 14:58

You must log in to answer this question.

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