Now, everytime I want to use hspace/vspace/... I always have to type "mm" behind my number and I often forget it. Is it possible to make sure that latex "knows" my units are in mm?
2 Answers
How about defining the following macros in the preamble
\newcommand\myhsp[1]{\hspace{#1mm}}
\newcommand\myvsp[1]{\vspace{#1mm}}
and writing \myhsp{7}
, \myvsp{12}
, etc in the body of the document?
This is safer than redefining the way \hspace
and \vspace
operate. These two macros are used in lots of LaTeX kernel commands, and modifying them has the potential to precipitate mysterious crashes. Don't even think about going there.
Using @TeXnician's suggestion, the following could be an easy implementation:
\documentclass[]{article}
\makeatletter
\newcommand*{\hspacemm}{\@ifstar{\hspacemm@@}{\hspacemm@}}
\newcommand*{\hspacemm@@}[1]{\hspace*{ #1 mm}}
\newcommand*{\hspacemm@}[1]{\hspace{ #1 mm}}
\newcommand*{\vspacemm}{\@ifstar{\vspacemm@@}{\vspacemm@}}
\newcommand*{\vspacemm@@}[1]{\vspace*{ #1 mm}}
\newcommand*{\vspacemm@}[1]{\vspace{ #1 mm}}
\makeatother
\begin{document}
\noindent
\hspacemm*{10}This \hspacemm{20}is spaced\\
This not
\end{document}
\hspace
and\vspace
? Maybe there is a way to automatically generate your desired format without putting in manual spaces.