0

Hi! :) with

\usepackage{amsmath}
\mathchardef\mhyphen="2D
{\catcode`-=\active\gdef-{\mhyphen}}
\AtBeginEnvironment{table}{\mathcode`-="8000}

it was possible for me to shorten the minus symbol in the table-environment. In my table I also got some formulas in the $...$-sourrounding. Just there I would like to have a "normal" minus (not short). Is that possible? (so to sum up: short minus-symbols in the table, but longer ("normal") minus-symbols in the table whenever I write something in $...$). If someone could help me, I would be grateful! :)

MaZie
  • 3
  • Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for the users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – samcarter_is_at_topanswers.xyz Dec 29 '22 at 13:45
  • 1
    Sorry, but the requirement is contradictory. What do you mean by “short minus in the table”? You get \mhyphen substituted for the standard minus only in math. – egreg Dec 29 '22 at 13:50
  • sorry for my bad English and thanks for the reply! with "short minus" I mean that it is a little smaller (shorter) than the normal one...I got a lot of tables and just wondered if it is possible to use this setting and add an additional "commando", so that whenever I write something (a formula) in $...$ in the table → just in the formula the "-" is "the normal one" (not shortened / smaller)...(because I already have a lot of tables I would be very glad if I wouldn't have to change the "-" symbol to \text{-} or something like that although that would work...) – MaZie Dec 29 '22 at 14:18
  • I believe what egreg is pointing out is your code only affects "-" in math mode. "-" is still a normal "-" outside of $...$. You could instead set the catcode of - to \active and have that substitute to \mhyphen (which you'd need to \chardef, and you'd need to change its catcode inside math). But why go through all this trouble? Why not just change "-" outside of math into \mhyphens? – Slurp Dec 29 '22 at 15:21
  • If I understand well, you are asking to print - as minus (you are calling this long minus) whenever the number is inside $...$ (i.e. math mode) and you want to print - as - (i.e. hyphenation character, you are calling it badly as short minus) whenever it is outside the $...$, i.e. outside the math mode. But this is default TeX behavior. You need nod to set any additional macro in order to get this feature. – wipet Dec 30 '22 at 09:10

1 Answers1

4

I guess you want the - signs in the negative numbers to be "short". And the other minus signs to be normal math mode minus signs. Your code with the \mhyphen trick prevents the latter, so you should get rid of it.

The - signs in the numbers are then long, because you typeset the numbers in math mode (number-mode = math). So for a start you should use number-mode = text, but that is not enough, because siunitx replaces the - in text mode with \textminus. So we must replace \textminus in the table back to a normal -.

\usepackage{siunitx}                        %% um Tabellen am Dezimalpunkt auszurichten
\sisetup{input-symbols = (), output-decimal-marker = {.}, number-mode = text, table-format=3.3, table-space-text-post={\textsuperscript{***}\,\,\,}, table-space-text-pre = {\,\,\,-}, separate-uncertainty=true}

%%%braucht man für die kurzen Minus-Zeichen \usepackage{amsmath} %\mathchardef\mhyphen="2D %{\catcode`-=\active\gdef-{\mhyphen}} \AtBeginEnvironment{table}{\def\textminus{-}}

Werner
  • 603,163
  • that's genius, thank you so much, it works perfectly!! – MaZie Dec 29 '22 at 17:45
  • +1. I would be tempted to change s^{CDS} to s^{\mathrm{CDS}} -- CDS is likely an acronym for "credit default swap" -- and Adj. $R^2$ to Adj.\ $R^2$ as the . serves to abbreviate a word rather than mark the end of a sentence. – Mico Dec 29 '22 at 18:31