1

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?

3
  • 1
    Welcome to TeX.SX! Why not simply defining an own version that doesn't interfere with TeX's units?
    – TeXnician
    Oct 31, 2017 at 13:57
  • 1
    Can you give some example when you use \hspace and \vspace? Maybe there is a way to automatically generate your desired format without putting in manual spaces. Oct 31, 2017 at 14:02
  • it's just in beamer when making my slides, to shift the text sometimes Oct 31, 2017 at 14:09

2 Answers 2

3

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.

1

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .