TransWikia.com

How to create a number line with custom tick marks and not numbers?

TeX - LaTeX Asked by Trap.Lord on December 13, 2020

I have seen examples of regular number lines on here, but I am having trouble making something that has variables for its tick marks. Something like this:

enter image description here

Your help would be appreciated!

One Answer

This is an example of the custom axis drawn with Asymptote:

enter image description here

// custaxis.asy
//
// run 
//   asy custaxis.asy
// to get a standalone custaxis.pdf
//
settings.tex="pdflatex";
import graph;
size(6cm);
import fontsize;defaultpen(fontsize(8pt));
texpreamble("usepackage{lmodern}"+"usepackage{amsmath}"
  +"usepackage{amsfonts}"+"usepackage{amssymb}");
pen linePen=darkblue+0.8bp;
pen bgPen=paleyellow;
guide gaxis=arc((0,0),1,200,390);
guide gdots=subpath(gaxis,reltime(gaxis,0.45),reltime(gaxis,0.7));

draw(gaxis,linePen);

int n=8;

string fmark(int k){return (k>1)?string(k):"";}

for(int i=0;i<4;++i){
  tick(relpoint(gaxis,i/n),-plain.I*reldir(gaxis,i/n),ticksize);
}
for(int i=n;i>n-3;--i){
  tick(relpoint(gaxis,i/n),-plain.I*reldir(gaxis,i/n),ticksize);
}
label("$0$",relpoint(gaxis,0),-3*plain.I*reldir(gaxis,0));
label("$t$",relpoint(gaxis,1),-3*plain.I*reldir(gaxis,1));
for(int i=1;i<4;++i){
  label("$tfrac{"+fmark(i)+"t}n$",relpoint(gaxis,i/n),-3*plain.I*reldir(gaxis,i/n));
}
for(int i=1;i<3;++i){
  label("$tfrac{n-"+string(i)+"}n,t$",relpoint(gaxis,(n-i)/n),-3*plain.I*reldir(gaxis,(n-i)/n));
}
draw(gdots,bgPen+3bp);
draw(gdots,Dotted(linePen));

shipout(bbox(Fill(bgPen)));

Answered by g.kov on December 13, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP