2

There is an interesting discussion at https://ux.stackexchange.com/q/92941/107032 about how a Canadian / Mexican / US phone number needs to be written. The answers essentially state:

  1. If your audience is strictly in Canada / Mexico / US, use (###) ###-####

  2. If your audience is not strictly in this area, use +# ### ### #### , which corresponds to the E.123 norm.

I'm not looking to discuss what is the proper formatting (How to typeset telephone numbers properly? answers this question already), but how to properly typeset this first format.

There is a conversation about how the dash in the first case needs to be written in Latex at How to produce a figure dash ‒ (U+2012) with pdflatex and XCharter.

I have other questions:

  1. Should the numbers be entered in math mode?
  2. Should the spaces be unbreakable, or of another nature?
  3. Should the plus sign be something other than a plus sign? (This wikipedia page seems to use the "normal" + sign, but I was wondering if there was a different convention)

MWE:

\documentclass{standalone}
\begin{document}
% Solution from https://tex.stackexchange.com/a/335513/34551
    \newlength\figurewidth
    \newcommand\fdash
    {\settowidth\figurewidth{9}%
        \raisebox{0.6ex}{\makebox[\figurewidth]{\hrulefill}}%
    }
\begin{tabular}{c c c }
(607) 123-4567 & +22 607 123 4567 & Text mode\\
(607)~123-4567 & +22~607~123~4567 & Text mode, unbreakable spaces\\
\((607) 123-4567\) & \(+22 607 123 4567\) & Math mode\\
\((607)~123-4567\) & \(+22~607~123~4567\) & Math mode, unbreakable spaces\\
(607) 123\fdash4567 &  & Text mode, "custom" dashes\\
\((607) 123\fdash4567\) &  & Math mode, "custom" dashes
\end{tabular}

\end{document}

enter image description here

7
  • 2
    For US telephone numbers, the parentheses and hyphen are \textit{pass\'e}. Where I live, every call requires using the area code. Unbreakable spaces are good, though. – John Kormylo Apr 3 '19 at 3:32
  • @JohnKormylo Thanks for your comment. I'm not trying to re-open the discussion at ux.stackexchange.com/q/92941/107032 , but simply to "implement" their recommendations using latex. I take good note that you and Kurt agree that unbreakable spaces are a must. – Clément Apr 3 '19 at 3:47
  • 1
    You might want to take a look at the phonenumbers package to automatize the formatting of phone numbers ctan.org/pkg/phonenumbers. – KersouMan Apr 3 '19 at 6:44
  • Do you have any news for us? Is the issue solved? How? – Mensch Aug 25 '19 at 17:07
  • 1
    Possible duplicate of How to typeset telephone numbers properly? – Franklin Yu Sep 5 '19 at 15:56
1

You can define a boolean that chooses different branches:

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\nanp}{mm}
 {% #1 = area code, #2 = phone number
  \bool_if:NTF \g_clement_camxus_bool
   {
    \clement_camxus:nn { #1 } { #2 }
   }
   {
    \clement_noncamxus:nn { #1 } { #2 }
   }
 }

\NewDocumentCommand{\nonCAMXUS}{}
 {
  \bool_gset_false:N \g_clement_camxus_bool
 }

\bool_new:N \g_clement_camxus_bool
\bool_gset_true:N \g_clement_camxus_bool

\cs_new_protected:Nn \clement_camxus:nn
 {
  (#1)\nobreakspace
  \tl_range:nnn { #2 } { 1 } { 3 }\nobreakspace
  \tl_range:nnn { #2 } { 4 } { 7 }
 }

\cs_new_protected:Nn \clement_noncamxus:nn
 {
  +1\nobreakspace#1\nobreakspace
  \tl_range:nnn { #2 } { 1 } { 3 }\nobreakspace
  \tl_range:nnn { #2 } { 4 } { 7 }
 }

\ExplSyntaxOff

\begin{document}

\nanp{212}{3456789}

\nanp{212}{345 6789}

\nonCAMXUS

\nanp{212}{3456789}

\nanp{212}{345 6789}

\end{document}

enter image description here

Since phone numbers are not “mathematical numbers”, they should not be in math mode and change shape according to the context. The spaces should be unbreakable, because a phone number must not be broken across lines. The plus sign is internationally recognized to stand for the local trunk code for international calls.

2
  • Thanks. My question was mainly the three sub-questions, "Should the numbers be entered in math mode? / Should the spaces be unbreakable, or of another nature? / Should the plus sign be something other than a plus sign?", and I can't really read the answer off your code. – Clément Sep 5 '19 at 17:47
  • 1
    @Clément I added my opinions about the first two points. The + should not be anything else. – egreg Sep 5 '19 at 19:45

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.