or
Diaa
tikz
For the following, how can I perfectly center both vertically and horizontally the drawing since it seems to be slightly shifted up and left?

![texstudio_EfiTAz_1.jpg](/image?hash=152044873c58e2f951bf500fe7837515f313a722aea752080fd4d709e0625724)


\documentclass{article}

\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage[type=none]{fgruler}

\usepackage[
a4paper , includeheadfoot , right = 10mm , left = 10mm , top = 0 mm, headheight = 0 mm, headsep = 5 mm, foot = 5 mm, bottom = 0 mm, showframe
]{geometry}

% http://tex.stackexchange.com/a/15002/100384
\newcommand*{\getlength}[2]{%
% Convert to cm and round to two fractional digits:
\pgfmathsetmacro#1{round(0.0351459804*#2)}%
}

\pagestyle{empty}

\begin{document}
\vspace*{\fill}\vskip-\topskip
\centering
\begin{tikzpicture}
\pgfmathsetmacro{\Hfactor}{0.95}% 0.9
\pgfmathsetmacro{\Wfactor}{0.95}
\getlength{\yMax}{\Hfactor*\textheight}
\getlength{\xMax}{\Wfactor*\textwidth}
\begin{axis}[
set layers,
width=\Wfactor\textwidth, height=\Hfactor\textheight,
scale only axis, name=border,
x = 1cm, y = 1cm,
xtick={0,1,...,\xMax},
ytick={0,1,...,\yMax},
minor xtick={0,0.1,0.2,...,\xMax},
minor ytick={0,0.1,0.2,...,\yMax},
tick style = {line width = 0.6pt, black!40!white},
minor tick style = {draw = none},
major tick style = {draw = none},
ticklabel style = {draw = none},
xticklabels=\empty,
yticklabels=\empty,
axis line style = {-latex},
grid = both,
minor grid style={line width=0.2pt, black!20!white},
major grid style={line width=0.6pt, black!60!white},
ymin=0, ymax=\yMax,
xmin=0, xmax=\xMax,
]
\begin{pgfonlayer}{axis grid}
\draw[line width=0.40pt, step=0.5cm, black!40!white] (axis cs: 0, 0) grid (axis cs: \xMax, \yMax);
\end{pgfonlayer}
\end{axis}
%        \pgfresetboundingbox
%        \path (border.south west) (border.north east);
%        \draw[red] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}\vspace*{\fill}
\fgruler{lowerleft}{10mm}{5mm}
\fgruler{upperright}{10mm}{5mm}
\end{document}


Diaa
I received [an answer](https://tex.stackexchange.com/a/530044/2288) on TEX.SX as follows:


\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage{siunitx}
% http://tex.stackexchange.com/a/15002/100384
\newcommand*{\getlength}[2]{%
% Convert to cm and round to two fractional digits:
\pgfmathsetmacro#1{round(0.0351459804*#2)}%
}
\newsavebox{\gridbox}
\savebox\gridbox{\begin{tikzpicture}
\pgfmathsetmacro{\width}{\paperwidth-2cm}
\pgfmathsetmacro{\height}{\paperheight-2cm}
% we will need some length in cm, without units, and rounded
\getlength{\yMax}{\height}
\getlength{\xMax}{\width}
\begin{axis}[
set layers,
width=\width, height=\height,
scale only axis, name=border,
x = 1cm, y = 1cm,
xtick={0,1,...,\xMax},
ytick={0,1,...,\yMax},
minor xtick={0,0.1,0.2,...,\xMax},
minor ytick={0,0.1,0.2,...,\yMax},
tick style = {line width = 0.6pt, black!40!white},
minor tick style = {draw = none},
major tick style = {draw = none},
ticklabel style = {draw = none},
xticklabels=\empty, %xlabel = \empty,
yticklabels=\empty, %ylabel = \empty,
axis line style = {-latex},
grid = both,
minor grid style={line width=0.2pt, black!20!white},
major grid style={line width=0.6pt, black!60!white},
ymin=0, ymax=\yMax,
xmin=0, xmax=\xMax,
]
%\begin{pgfonlayer}{axis grid}% redundant
%\draw[line width=0.40pt, step=0.5cm, black!40!white] (axis cs: 0, 0) grid (axis cs: \xMax, \yMax);
%\end{pgfonlayer}
\end{axis}
\pgfresetboundingbox
\path (border.south west) (border.north east);
\end{tikzpicture}}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\node at (current page.center) {\usebox\gridbox};
\end{tikzpicture}
\end{document}

tikz: Perfectly centering a graph paper drawing
I mean \documentclass{article}
\usepackage{pgf}
\begin{document}
\pgfmathsetmacro{\myrnd}{50*rnd}%
\pgfmathsetmacro{\mycm}{\myrnd*1pt/1cm}%
\myrnd pt is equal to \mycm cm.
\end{document}. You can divide any distance by 1cm, and then know how many cm this corresponds to.
There is  an item about mail notifications on github, see https://github.com/topanswers/topanswers/issues/25
Thanks!
I am so sorry, but I don't understand what you actually mean. For example,

\newcommand*{\getlength}[2]{%
% Convert to cm and round to two fractional digits:
\pgfmathsetmacro#1{round(0.0351459804*#2)}%
}

converts to cm; would you please elaborate more your way of doing so?
Yes, by email.
I added an answer with a link to the original one on TEX.SX.
If you cross-post the same question on multiple sites, please include links to each other in both posts. This will save users from their spending time on trying to solve your problems when they are already solved elsewhere.
do you mean by email or something like that?
I actually do get notifications. One may have to reload the page, but I only responded above because I got a notifier.
This is very easy. \pgfmathsetmacro{\mydim}{3pt+4cm} will convert the length into points, i.e. \mydim pt is the length in pt units. If you do \pgfmathsetmacro{\mycm}{\somelength/1cm}, where \somelength is some length, \mycm will contain the information of how many cm this is.
Diaa
There should be something to notify me of any activity relevant to me when I am out of topanswers in order to prevent the awkward silence.
I already received an answer on TEX.SX, but I would be happy if you show me how to convert units using pgf.
I am sorry, but I forgot to come here and check my question since I got an answer on TEX.SX.
I accidentally came here to check the traffic, and I found that many of you waited for my response. I actually didn't feel any notifications outside topanswers, which is a big minus in my opinion.
Sounds good with unsubscribe -- a bit like on github
yes I think we do need that with an 'unsubscribe' option
Just an idea: how about pining the OP for all messages?
Jack Douglas
@Diaa ^^^ in case you weren't pinged!
samcarter
![Screen Shot 2020-02-27 at 10.56.53.png](/image?hash=e7e4ac50fce8f72f261e4ffcb5f2265659069494cab69abbd6d77dd72906c45b)
samcarter
![Screen Shot 2020-02-27 at 10.56.57.png](/image?hash=7ce04a5817a9ad8e6a9e47198a2f6f5db370377d6c2af62593700db708d68d4f)
samcarter
Taking some quick and dirty measurements with the measuring tool from inkscape it seems to be pretty much in the centre:
marmot
Hi, welcome! Would you be OK with an overlay solution? BTW, you can use pgf to convert cm to pt, this may be safer.
image added
You can add that image to your answer (just so you know).
You can take a look at the output here https://i.ibb.co/X8nGxx3/texstudio-Efi-TAz-1.jpg , and you will notice it is shifted a bit when referring to the vertical and horizontal rulers
@Diaa For me it looks pretty centred (but I didn't measure and I don't know how your output should look like). Do you know the tikzpagenodes package/library (you can see its documentation by using texdoc tikzpagenodes, by visiting its CTAN page, or by visiting http://texdoc.net/ and searching for it)?