%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to Overleaf --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you open the
% 'Share' menu, you can invite other users to edit at the same
% time. See www.overleaf.com/learn for more info. Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Semi-log and log-log graph paper, drawn with TikZ at exact print scale.
% Licence: CC BY 4.0. Compile with pdfLaTeX (or LuaLaTeX / XeLaTeX).
%
% The document body (bottom of this file) prints four pages:
% 1-cycle, 2-cycle and 3-cycle semi-log paper, and 2 x 3 cycle log-log paper.
% Delete the pages you don't need, or change the numbers in braces.
% Print at "Actual size" / 100 %, not "Fit to page", to keep the scale.
\documentclass{article}
% ---- 1. Paper size -------------------------------------------------------
% a4paper or letterpaper. The margin is kept free of lines on every side.
\usepackage[a4paper,margin=10mm]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\setlength{\parindent}{0pt}
% ---- 2. Settings ---------------------------------------------------------
\newcommand{\LinStep}{5} % semi-log linear axis: cell size in mm (1/4 in = 6.35)
\newcommand{\LinMajor}{2} % heavier line every N cells (use 4 with 6.35 mm)
\newcommand{\LabelSpace}{5} % mm kept free left of / below the grid for the 1-9 labels
\definecolor{gpMinor}{HTML}{8EB1D6}
\definecolor{gpMajor}{HTML}{4F7FB5}
\definecolor{gpInk}{HTML}{555555}
\tikzset{
gp fine/.style ={line width=0.35pt, gpMinor}, % log subdivisions, linear cells
gp int/.style ={line width=0.56pt, gpMajor}, % 2, 3, ... 9 within a decade
gp decade/.style ={line width=1.12pt, gpMajor}, % 1, 10, 100, ...
gp major/.style ={line width=0.8pt, gpMajor}, % every \LinMajor-th linear line
gp label/.style ={gpInk, font=\sffamily\fontsize{6}{7}\selectfont, inner sep=1.2pt},
}
% ---- 3. Drawing macros ---------------------------------------------------
% One line of a log axis at position #2 (mm along the axis), style #3.
% #1 = v: the axis runs up the page (lines are horizontal), h: across the page.
% \gpFrom / \gpTo: where the line starts and ends across the axis (mm).
\newcommand{\gpLine}[3]{%
\if#1v\draw[#3] (\gpFrom mm,#2 mm) -- (\gpTo mm,#2 mm);%
\else \draw[#3] (#2 mm,\gpFrom mm) -- (#2 mm,\gpTo mm);\fi}
\newcommand{\gpLabel}[2]{%
\if#1v\node[gp label, anchor=east] at (\gpFrom mm,#2 mm) {\gpText};%
\else \node[gp label, anchor=north] at (#2 mm,\gpFrom mm) {\gpText};\fi}
% \gpLogAxis{v|h}{start mm}{length mm}{cycles}{across from mm}{across to mm}
% Lines at 1, 2, ... 9 in every decade, labelled 1-9. Finer lines (1-2 by 0.1,
% 2-5 by 0.2, 5-10 by 0.5) only where they stay at least 0.78 mm (2.2 pt) apart.
\newcommand{\gpLogAxis}[6]{%
\def\gpFrom{#5}\def\gpTo{#6}%
\pgfmathsetmacro{\gpDec}{#3/#4}%
\foreach \gpC in {1,...,#4}{%
\pgfmathsetmacro{\gpBase}{#2+(\gpC-1)*\gpDec}%
\foreach \ba/\bb/\bs/\bn/\bk in {1/2/0.1/9/10, 2/5/0.2/14/5, 5/10/0.5/9/2}{%
\pgfmathsetmacro{\gpGap}{\gpDec*(log10(\bb)-log10(\bb-\bs))}%
\ifdim\gpGap pt>0.78pt
\foreach \gpI in {1,...,\bn}{%
\pgfmathtruncatemacro{\gpRest}{mod(\gpI,\bk)}%
\ifnum\gpRest>0
\pgfmathsetmacro{\gpPos}{\gpBase+\gpDec*log10(\ba+\gpI*\bs)}%
\gpLine{#1}{\gpPos}{gp fine}%
\fi}%
\fi}%
\foreach \gpK in {2,...,9}{%
\pgfmathsetmacro{\gpPos}{\gpBase+\gpDec*log10(\gpK)}%
\gpLine{#1}{\gpPos}{gp int}%
\def\gpText{\gpK}\gpLabel{#1}{\gpPos}}%
\gpLine{#1}{\gpBase}{gp decade}%
\def\gpText{1}\gpLabel{#1}{\gpBase}}%
\pgfmathsetmacro{\gpPos}{#2+#3}%
\gpLine{#1}{\gpPos}{gp decade}%
\def\gpText{1}\gpLabel{#1}{\gpPos}}
% Text area in whole millimetres (1 mm = 2.84527 TeX pt).
\newcommand{\gpArea}{%
\pgfmathsetmacro{\gpAvailW}{floor(\textwidth/2.84527-\LabelSpace+0.01)}%
\pgfmathsetmacro{\gpAvailH}{floor(\textheight/2.84527-1+0.01)}}
% \SemiLogPage{cycles}: log scale up the page, linear cells of \LinStep mm across.
\newcommand{\SemiLogPage}[1]{%
\gpArea
\pgfmathtruncatemacro{\gpN}{floor(\gpAvailW/\LinStep+0.0001)}%
\pgfmathsetmacro{\gpW}{\gpN*\LinStep}%
\pgfmathsetmacro{\gpX}{\LabelSpace+(\gpAvailW-\gpW)/2}%
\pgfmathsetmacro{\gpXe}{\gpX+\gpW}%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\textwidth,\gpAvailH mm);
\foreach \gpI in {0,...,\gpN}{%
\pgfmathtruncatemacro{\gpRest}{mod(\gpI,\LinMajor)}%
\pgfmathsetmacro{\gpPos}{\gpX+\gpI*\LinStep}%
\ifnum\gpRest=0 \def\gpSty{gp major}\else\def\gpSty{gp fine}\fi
\ifnum\gpI=\gpN \def\gpSty{gp major}\fi
\draw[\gpSty] (\gpPos mm,0) -- (\gpPos mm,\gpAvailH mm);}
\gpLogAxis{v}{0}{\gpAvailH}{#1}{\gpX}{\gpXe}
\end{tikzpicture}\par\newpage}
% \LogLogPage{cycles across}{cycles up}: log scales on both axes.
\newcommand{\LogLogPage}[2]{%
\gpArea
\pgfmathsetmacro{\gpH}{\gpAvailH-\LabelSpace}%
\pgfmathsetmacro{\gpXe}{\LabelSpace+\gpAvailW}%
\pgfmathsetmacro{\gpYe}{\LabelSpace+\gpH}%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\textwidth,\gpAvailH mm);
\gpLogAxis{h}{\LabelSpace}{\gpAvailW}{#1}{\LabelSpace}{\gpYe}
\gpLogAxis{v}{\LabelSpace}{\gpH}{#2}{\LabelSpace}{\gpXe}
\end{tikzpicture}\par\newpage}
% ---- 4. Pages ------------------------------------------------------------
\begin{document}
\SemiLogPage{1}
\SemiLogPage{2}
\SemiLogPage{3}
\LogLogPage{2}{3}
\end{document}