1

Is there any package that can automatically display the year as "b.C" (before Christ) if the value is negative?

I've code for that, but I am looking for a more elegant solution, or even better a package that would do this automatically. My solution also seems to generate an extra space afterwards.

I've look through siunitx and datetime2 but none seem to work like I need.

I am using the following (for Portuguese):

\newcommand{\byear}[1]{%
    \ifnum #1<0
    {-#1} a.C.\
    \else
    {#1} d.C.\
    \fi
}
4
  • 1
    I have a package which lets you configure the labels for BCE and CE. However, it only does that in passing - it isn't something you'd want to load for that purpose.
    – cfr
    Commented May 11 at 20:39
  • If you are using that in text the - will make a hyphen not a minus sign, and -4 will print as --4 as you are not using any arithmetic, just prefixing with a hyphen. perhaps you want \number-#1 Commented May 11 at 20:46
  • 2
    you are forcing the extra space with \ use \@% to get a normal (not end of space) behaviour for . wihout adding space. Commented May 11 at 20:48
  • 1
    Don't forget that there was no year zero. 1BC went straight into 1AD. Commented May 12 at 1:20

1 Answer 1

1

enter image description here

Using \number to negate the input, and \@ to force a normal . not end of sentence, without adding extra space.

\documentclass{article}
\newcommand{\byear}[1]{%
    \ifnum #1<0
    {-#1} a.C.\
    \else
    {#1} d.C.\
    \fi
}

\newcommand{\bbyear}[1]{%
    \ifnum #1<0
    \number-#1\ a.C.\@%
    \else
    #1\ d.C.\@%
    \fi
}
\begin{document}

\byear{100}  \byear{-100} \byear{55}

\bbyear{100}  \bbyear{-100} \bbyear{55}



\end{document}
1
  • actually the \@ isn't needed as you have a capital here but if the convention used a lowercase letter it would be needed. Commented May 11 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .