4

I was suggested by my thesis referee that parenthesizes () and citation brackets [] (I only use square brackets generated by biblatex)should always be in upright.

This is indeed the same question as Upright parentheses in italic text and How to get upright parentheses in the whole document?.

But the solution (embrac) there is not fully satisfactory. First, it produces errors for \emph{\(math\) not work!}; second, it does not work for italic texts in theorem environment.

Since this is a style problem, I hope that there is no need to modify the code of the main file manually.

2

What about this:

\def\adef#1{\catcode`#1=13 \bgroup \lccode`\~=`#1\lowercase{\egroup\def~}}
\let\emphOri=\emph
\def\emph{\bgroup\adef({\ifmmode(\else{\rm(}\fi}\adef){\ifmmode)\else{\/\rm)}\fi}\emphA}
\def\emphA#1{\emphOri{#1}\egroup}

\emph{text (text) $\bigl( f(x) + y\bigr)$ text}

If you need to redefine \ithsape too, add the lines:

\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\addto\itshape{\adef({\ifmmode(\else{\rm(}\fi}\adef){\ifmmode)\else{\/\rm)}\fi}}

{\itshape text (text) $\bigl( f(x) + y\bigr)$ text}

I mean that this code is more compact and more readable than embrac.sty.

Edit: If you need to give the same behaviour to another braces [square baces, for example], you can try this:

\def\adef#1{\catcode`#1=13 \bgroup \lccode`\~=`#1\lowercase{\egroup\def~}}
\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\activebraces#1#2{\adef#1{\ifmmode#1\else{\rm#1}\fi}\adef#2{\ifmmode#2\else{\/\rm#2}\fi}}
\let\emphOri=\emph
\def\emph{\bgroup\activebraces()\activebraces[]\emphA}
\def\emphA#1{\emphOri{#1}\egroup}
\addto\itshape{\activebraces()\activebraces[]}

But I warn: this will not probably work with automatically generated braces (aka from biblatex) because these braces are already tokenized in the macro. I didn't try it but I assume this behavior. You need to find the braces in the package and replace them by \rm version or use some package option (for setting the type of braces). I don't know, sorry, I am not LaTeX specialist.

  • This doesn't work for \itshape since it relies on the usage of \emph. – Werner Jun 7 '14 at 4:05
  • @Werner OK, I've added two next lines for \itshape. But this was not required by the question. – wipet Jun 7 '14 at 5:21
  • The question states: "second, it does not work for italic texts in theorem environment." I assumed this references some form of \itshape. – Werner Jun 7 '14 at 5:32
  • It seems nice! Could you modify your code that handles square brackets as well? I only use square brackets generated by biblatex. – Ma Ming Jun 7 '14 at 15:26
  • 1
    @MaMing You can try to set \def\bibleftbracket{{\rm[}} \def\bibrightbracket{{\rm]}}. This is a result from my little reverse engineering of biblatex. This is not mentioned in 300 pages manual. And this is without warranty because I didn't try it with real data because I never use such unnecessarily complicated macro packages. – wipet Jun 9 '14 at 6:45
1

The [] brackets in citations can be fixed using the cite package:

\usepackage{cite}

\def\citeleft{\begingroup\rm[}
\def\citeright{]\endgroup}

This doesn't help with the remaining brackets ()'s in the document. FWIW, I always put mine in math mode.

  • hello, could you modify your codes to handle biblatex? It seems that biblatex and cite are incompatible. – Ma Ming Jun 7 '14 at 18:41
  • Sorry Ma, I don't have any experience with biblatex. – Andrew Jun 7 '14 at 23:46

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.