# How to make a ruler with logarithmic divisions?

I'm trying to make a slider for a custom cut-out slide ruler with logarithmic increments/divisions on each side. On one side the scale needs to go from 100 to 5000. On the other it needs to go from 0.1 to 10.

I can make a ruler, e.i. like this:

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[rotate=0,transform shape]
%% Draws a 15 cm ruler ''box''
\draw (-0.2,0) rectangle (15.5,1);
%% Lower side divisions in cm
% Draws long line every 1 cm
\foreach \x in {0,1,...,15}{
\draw (\x,0) -- (\x,0.2)node[above,scale=0.4]{\x};
}
% Draws medium line every 0.5 cm
\foreach \x in {0.1,0.2,...,14.9}{
\draw (\x,0) -- (\x,0.075);
}
% Draws short line every 0.1 cm
\foreach \x in {0.5,1,...,14.5}{
\draw (\x,0) -- (\x,0.15);
}

%% Upper side divisions in inches
% Draws long line every 1 in
\foreach \x in {0,1,...,6}{
\draw (\x in,1) -- (\x in,0.8)node[below,scale=0.4]{\x};
}
% Draws medium line every 0.5 in
\foreach \x in {0.1,0.2,...,5.9}{
\draw (\x in,1) -- (\x in,0.925);
}
% Draws short line every 0.1 in
\foreach \x in {0.5,1,...,5.5}{
\draw (\x in,1) -- (\x in,0.85);
}
\end{tikzpicture}
\end{document}


But this have just normal, even increments. I've been looking everywhere to find out how to make them logarithmic, but I've had no luck so far. The closest I've come is axis and pgfplots, but I hav no ide how to utilize that for a slider/ruler like the one over.

Any tips or points in the right direction would be much appreciated!

In advance thanks to anyone who can help.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CLARIFICATION/UPDATE ON QUESTION:

Hi again.

I was not precise earlier. I want to to make a ruler about similar to this one:

It doesn't need to be exactly like it and internal placement of the scales is for now not important. I just want to know how to make the logarithmic divisions. I have seen the other post seen here: How can I make a slide rule in TikZ?

The solution here is a logarithmic grid system with a hidden axis, producing something like this:

This gave me a couple of problems: I haven't figured out how to put custom numbering on this, i.e. (0.1,0.2,0.3,...1,2,3,...10,20,30,...100) instead of 1e0.1,1e0,2, and so on. The other is to have two og them side by side in a ''ruler'' ment for cut-out.

If \foreach can do this directly it would be perfect. But I haven't been able to find anything about it anywhere.

I hope this made my question a little clearer.

• You can do all of that with one single \foreach by the way. But that's unrelated. You want it to go from 100 to 5000 but with what steps? If possible, I'd like to see a desired output image, done with external software. – Alenanno Jul 7 '15 at 20:26
• Look here tex.stackexchange.com/questions/194120/… as I think this will provide the additional information you need. – R. Schumacher Jul 7 '15 at 20:30
• Hi. Thanks for answers. I've seen that post. But I can't figure out how to go from that logarithmic grid with one hidden axis, to the numbered ''ruler'' I need.I have updated my question to make it more precise. – Hedinn Jul 9 '15 at 7:24

Here a solution for your problem. The values can be adjusted by choosing other calculations in the foreach-loops. This example uses a loop for creating the steps from 1 to 10 by applying a multiplicator (0.1, 1 and 10). This scope gets shifted to fit its position.

To get your orientation right you havee to rotate your tikzpicture (you can also use another scope) and adjust the node's position and rotation.

\documentclass[tikz, border=6mm]{standalone}

\begin{document}
\begin{tikzpicture}[scale=4, rotate=90]
\foreach \i\s in {0.1/0,1/1,10/2} {
\begin{scope}[xshift=\s cm]
\foreach \x [evaluate=\x as \y using log10(\x), evaluate=\x as \l using \x*\i] in {1,...,10} {
\draw (\y,0) -- ++(0,.25) node [left, rotate=0] {\tiny \pgfmathprintnumber{\l}};
}
\foreach \x [evaluate=\x as \y using log10(\x)] in {1,1.2,...,10} {
\draw (\y,0) -- ++(0,.1);
}
\end{scope}
}
\draw (-.1,0) rectangle ++(3.2,.5);
\end{tikzpicture}
\end{document}


• Hi moospit! This is exactly what I was looking for! I can now tweek this to my needs. Thanks a lot! :) – Hedinn Feb 23 '16 at 7:45