5

My problem seems rather simple but I can't manage it. I want to describe bytes in this way

0000 xxxx
0010 1xxx

I tried by writing

0000 \times\times\times\times
0010 1\times\times\times

but this gave me too much spaces between the crosses (something like :

0000 x x x x
0010 1 x x x 

I removed some spaces by doing like here (Removing spaces between "words" in math mode)

0000 {\times}{\times}{\times}{\times}

but this is not enough... Do you have any idea on how to do so?

I add here a MWE, as asked by some.

\documentclass[a4paper,titlepage]{article}
\usepackage{mathtools}
\usepackage{amssymb, scalerel}

\begin{document}
I want the bytes $0000\;1{\times}{\times}{\times}$ to express an error in my algorithm.
\end{document}
mwoua
  • 1,369
  • 3
  • 15
  • 24

4 Answers4

9

The symbol \times has rather wide sidebearings. I propose two solutions:

  1. a reduced size symbol that occupies the same horizontal space as a digit;

  2. the \times symbol at its natural width, with reduced sidebearings

\documentclass[a4paper]{article}

\newcommand{\plh}{%
  {\ooalign{$\phantom{0}$\cr\hidewidth$\scriptstyle\times$\cr}}%
}
\newcommand{\PLH}{{\mkern-2mu\times\mkern-2mu}}

\begin{document}
I want the bytes $0000\;1\plh\plh\plh$ to express an error in my algorithm.

I want the bytes $0000\;1\PLH\PLH\PLH$ to express an error in my algorithm.
\end{document}

enter image description here

egreg
  • 1,121,712
  • Can I renewcommand \times? – Hotschke May 23 '18 at 11:03
  • @Hotschke You could, but why? – egreg May 23 '18 at 12:24
  • I have a densely packed table with math entries which I need to squeeze together. My first naive attempt using your answer by replacing \newcommcand{\plh} with \renewcommand{\times} did not work. However, I already resolved this with \setlength{\medmuskip}{0mu}. I was afraid that this would have too many side effects. – Hotschke May 23 '18 at 12:53
  • @Hotschke That setting has many side effects if you don't control precisely the environment where you issue it. – egreg May 23 '18 at 13:15
  • What does plh stand for? – Mateen Ulhaq May 18 '20 at 16:06
  • @MateenUlhaq After six years, I have no idea why I chose that name. One can use any other name, though. – egreg May 18 '20 at 16:49
5
\documentclass{article}
\begin{document}
I want the bytes $0000\;1{\times}{\times}{\times}$ to express an error in my algorithm.

I want the bytes \texttt{0000 1xxx} to express an error in my algorithm.

I want the bytes \textsf{0000 1xxx} to express an error in my algorithm.

\end{document}

enter image description here

Sigur
  • 37,330
  • Event if I don't think it answers correctly my question, I will use your solutions. It looks better in my work. Thanks! – mwoua Mar 23 '14 at 16:33
3

What do you think of using mathsf?

    \documentclass[a4paper,titlepage]{article}
    \usepackage{mathtools}
    \usepackage{amssymb, scalerel}

    \newcommand*{\x}{\mathsf{x}\mskip1mu}

    \begin{document}

    I want the bytes $0000\;1\x\x\x$ to express an error in my algorithm.

    \end{document} 

enter image description here

Bernard
  • 271,350
1

You can use negative spaces \!, or \!\! if one is not enough, which gives:

\documentclass[a4paper,titlepage]{article}
\usepackage{mathtools}
\usepackage{amssymb, scalerel}

\begin{document}
I want the bytes $0000\;1\times\!\!\times\!\times$ to express an error in my algorithm.
\end{document}
Spin
  • 41
  • 3
    Did you try with three \times? – egreg Mar 23 '14 at 16:33
  • Yes I do. It works too. You may refer to that question if you want to use more complex negative spacings: http://tex.stackexchange.com/questions/67912/large-negative-spaces. – Spin Mar 23 '14 at 16:36
  • @egreg, good question! – Sigur Mar 23 '14 at 16:36
  • Hum, sorry, this isn't working with 3 \times. But this does: $0000;1\times!!\times!\times$. – Spin Mar 23 '14 at 16:38
  • @Spin The spacing is inconsistent because \times is a binary operation symbol; you'd better use {\times} that forces it to ordinary. But in that case \! is too much. – egreg Mar 23 '14 at 16:39
  • 1
    Yep, I figured this out... It's not a very good idea to use this symbol in that kind of situation. – Spin Mar 23 '14 at 16:40