3

I'm attempting to make a table that visually mimics the WSJ markets page. Specifically, I'm hoping that there's a simple way to implement the visual from the Range column: wsjmarkets

It seems plausible to me that there's an established way to do this but I don't know how to describe what I'm looking for. The one option I can think of now would be to make it all in TikZ, but I'd rather avoid that complexity if possible.

Is there an easy way to put a bullet in a range box based on an input value?

3 Answers3

4

Something like this?

\documentclass{article}
\usepackage{booktabs}
\usepackage{tikz}
\newcommand\Range[1]{%
  \begin{tikzpicture}[scale=0.2]
    \fill[gray!40](0,0) rectangle (8,1);
    \foreach \x in {2,4,6}\draw[white,very thick](\x,0)--+(0,1);
    \fill[black](0.4+#1/100*7.2,0.5) circle (0.4);
  \end{tikzpicture}
}
\begin{document}
\begin{tabular}{l}
  \toprule
  RANGE\\\midrule
  \Range{50}\\
  \Range{100}\\
  \Range{0}\\
  \Range{12}\\
  \Range{62}\\\bottomrule
\end{tabular}
\end{document}

enter image description here

StefanH
  • 13,823
3

Yet another approach.

\documentclass{elsarticle}
\usepackage{xcolor,stackengine}
\def\greybox{\textcolor{gray!50}{\rule{8pt}{1.2ex}}}
\def\backgrid{\greybox\kern1pt\greybox\kern1pt\greybox\kern1pt\greybox}
\setbox0=\hbox{\backgrid}
\edef\backgridwd{\the\wd0}
\newcommand\Range[1]{\stackengine{0pt}{\backgrid}{%
  \kern#1\dimexpr\backgridwd\makebox[0pt]{$\mkern.5mu\bullet$}}{O}{l}{F}{F}{L}}
\begin{document}
\begin{tabular}{c}
\hline
Range\\
\hline
  \Range{.50}\\
  \Range{1.00}\\
  \Range{0}\\
  \Range{.12}\\
  \Range{.62}
\\
\hline
\end{tabular}
\end{document}

enter image description here

2

I ended up using the sparklines package:

\documentclass{article}
\usepackage{sparklines,booktabs}

\begin{document}
\definecolor{sparkspikecolor}{gray}{1}
\setlength{\sparkspikewidth}{1pt}
\setlength{\sparkdotwidth}{2pt}
\newcommand{\rangebox}[1]{
    \begin{sparkline}{10}
    \sparkrectangle 0 1
    \sparkspike .25 1
    \sparkspike .5 1
    \sparkspike .75 1
    \sparkdot #1 0.5 black
    \end{sparkline}
}

\begin{tabular}{c}
  \toprule
  Range 
  \\\midrule
  \rangebox{.2}\\
  \rangebox{1}\\
  \rangebox{0}\\
  \rangebox{.8}\\
  \rangebox{.95}\\\bottomrule
\end{tabular}

\end{document}

sparklines