2

I created a new command, however the spacement after calling it in the text, the there is an extra space than normal, E.G.:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\newcommand{\numproportion}[2]{%
#1\ensuremath{\text{:}}#2
}%
\begin{document}
\noindent
\numproportion{1}{2} Daniel\\
1:2 Daniel
\end{document}

enter image description here

Notes:

1. I'd like to have the spacement of the second line

2. I used ensuremath for eventually uses inside math mode, avoiding the spacement of : in this mode

  • By the way, what's the purpose of \ensuremath{\text{:}} instead of simply :? If your aim is to use \numproportion in math mode while getting no space around :, the way is \newcommand{\numproportion}[2]{#1{:}#2} – egreg Sep 24 '17 at 14:13
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Sep 26 '17 at 16:36
9
\newcommand{\numproportion}[2]{%
#1{:}#2% no space here says egreg
}%

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.