Typeset a series of characters with equal distances?

Make sure you typeset them it math-mode, i.e. $-$ and $+$.

Be aware that it makes a difference if you use a single math-mode or separate ones for them. The last sign has different spacing in the first case because it is taken as an unary sign but the others are operators.

Compare the following:

\documentclass{article}

\begin{document}

$-$$-$$-$$+$$+$$+$

$+$$+$$+$$+$$+$$+$

$-$$-$$-$$-$$-$$-$

$---+++$

$++++++$

$------$

\end{document}

Result:

Result


For the alignment with the other signs a, A and 0 I would recommend that you make macros for all and set the width manually the one of the widest (should be $+$).

This can be done either with \hbox to <length>{\hss <sign>\hss} (TeX) or using \makebox[<length>][c]{<sign>} (LaTeX). The width is provided by \settowidth{<length register>}{<content>}.

\documentclass[11pt, a4paper]{scrreprt}

\usepackage{booktabs}

\newlength{\slength}
\settowidth{\slength}{$+$}
\newcommand*{\Sz}{\makebox[\slength][c]{0}}
\newcommand*{\SA}{\makebox[\slength][c]{A}}
\newcommand*{\Sa}{\makebox[\slength][c]{a}}
\newcommand*{\Sp}{\makebox[\slength][c]{$+$}}
\newcommand*{\Sm}{\makebox[\slength][c]{$-$}}

\begin{document}

\begin{tabular}{cc}
\toprule
         1 &  \Sp\Sp\Sm  \\
         2 &  \Sp\Sm\Sp  \\
         3 &  \Sm\Sp\Sp  \\
         4 &  \Sz\Sz\Sz  \\
         5 &  \Sm\Sm\Sm  \\
         6 &  \Sz\Sz\Sz  \\
\midrule
         7 &  \Sm\Sp\Sm  \\
         8 &  \Sz\Sz\Sz  \\
         9 &  \Sp\Sm\Sm  \\
        10 &  \Sm\Sm\Sp  \\
        11 &  \Sp\Sp\Sp  \\
        12 &  \Sz\Sz\Sz  \\
\midrule
        13 &  \Sz\Sz\Sz  \\
        14 &  \Sz\Sz\Sa  \\
        15 &  \Sz\Sz\SA  \\
        16 &  \Sz\SA\Sz  \\
        17 &  \SA\Sz\Sz  \\
        18 &  \Sz\Sa\Sz  \\
        19 &  \Sa\Sz\Sz  \\
        20 &  \Sz\Sz\Sz  \\
\bottomrule
\end{tabular}

\end{document}

Result:

Result 2


\documentclass{minimal}
\begin{document}
\setlength{\parindent}{0pt}
\newlength{\stretchlen}\setlength{\stretchlen}{1em}
\def\splitterm{\_}
\newcommand{\stretchit}[1]{\leavevmode\realstretch#1\_}
\def\realstretch#1{%
    \def\temp{#1}%
    \ifx\temp\splitterm
    \else
    \hbox to \stretchlen{\hss#1\hss}\expandafter\realstretch
\fi}
\stretchit{abcd}\par
\stretchit{----}\par
\stretchit{++++}\par
\stretchit{-+-+}\par
\stretchit{0aA+}\par
\end{document}

\stretchit appends an underscore to its argument and passes it to \realstretch, which recursively 'eats' one letter at a time, and typesets it centered in an \hbox stretched to \stretchlen. All letters are thus equally wide, and since they are centered, aligned nicely.

--- solution for the question:

\documentclass[10pt, a4paper    ]{scrreprt}

\usepackage{booktabs}
\usepackage{collcell}
\usepackage{array}
\begin{document}


\setlength{\parindent}{0pt}
\newlength{\stretchlen}\setlength{\stretchlen}{1em}
\def\splitterm{\_}
\newcommand{\stretchit}[1]{\leavevmode\realstretch#1\_}
\def\realstretch#1{%
    \def\temp{#1}%
    \ifx\temp\splitterm
    \else
    \hbox to \stretchlen{\hss#1\hss}\expandafter\realstretch
\fi}

without the stretchit command

\begin{tabular}{cccccccc}
\midrule
         1 &        ++-             \\
         2 &        +-+             \\
         3 &        -++             \\
         4 &        000                  \\
         5 &        ---                 \\
         6 &       000               \\
\midrule
         7 &        -+-                 \\
         8 &       000                \\
         9 &        +--                 \\
        10 &        --+             \\
        11 &        +++             \\
        12 &        000             \\ 
\midrule
        13 &        000                  \\
        14 &        00a                   \\
        15 &        00A                   \\
        16 &        0A0                 \\
        17 &        A00                   \\
        18 &        0a0                  \\
        19 &        a00                  \\
        20 &        000                  \\
\toprule
\end{tabular}  

\medskip

\emph{with} the stretchit command

\begin{tabular}{c>{\collectcell\stretchit}c<{\endcollectcell}ccccccc}
\midrule
         1 &        ++-             \\
         2 &        +-+             \\
         3 &        -++             \\
         4 &        000                  \\
         5 &        ---                 \\
         6 &       000               \\
\midrule
         7 &        -+-                 \\
         8 &       000                \\
         9 &        +--                 \\
        10 &        --+             \\
        11 &        +++             \\
        12 &        000             \\ 
\midrule
        13 &        000                  \\
        14 &        00a                   \\
        15 &        00A                   \\
        16 &        0A0                 \\
        17 &        A00                   \\
        18 &        0a0                  \\
        19 &        a00                  \\
        20 &        000                  \\
\toprule
\end{tabular}  

\end{document}

one possible form to typeset your table would be to use a table column for each character:

\documentclass[11pt, a4paper]{scrreprt}
\usepackage{booktabs}

\newcommand\Pl{${}+{}$}
\newcommand\Mi{${}-{}$}

\begin{document}

\begin{tabular}{cc@{\hspace{-2pt}}c@{\hspace{-2pt}}c}
  \toprule
  1 & \Pl & \Pl & \Mi \\
  4 & 0 & 0 & 0 \\
 12 & a & 0 & A \\
 15 & 0 & 0 & A \\
  \bottomrule
\end{tabular}

\end{document}

Tags:

Macros

Spacing