2

For example, I have this sentence:

GeneA, GeneB, and GeneC have been found to have a role in RNA metabolism.

This is what I would like, format-wise:

GeneA, GeneB, and GeneC have been found to have a role in RNA metabolism.

I can achieve this with:

\textit{GeneA}, \textit{GeneB}, and \textit{GeneC} have been found to have a role in RNA metabolism.

Is there a way to italicise a list of words, but leaving the comma out as textit also italicises the commas? i.e.

\italiciselist{GeneA, GeneB}, and \textit{GeneC} have been found to have a role in RNA metabolism.

It's not a problem with 2 or 3 words needing italicising, but when it's longer, it would be much easier with a function which takes more than one word.

1
  • 1
    or \newcommand\z[1]{\textit{Gene#1}} then \z{A}, \z{B}, \z{C} – David Carlisle Oct 7 '20 at 10:21
3

From the example below, copy the lines between \makeatletter and \makeatother (inclusively) to the preamble of your document. They define your command \italiciselist.

\documentclass{article}
\makeatletter
\newcommand\italiciselist[1]{%
   \def\il@sep{}%
   \@for\il@gene:=#1\do{%
      \il@sep\textit{\il@gene}%
      \def\il@sep{, }%
   }%
}
\makeatother
\begin{document}
\italiciselist{GeneA,GeneB}, and \textit{GeneC} have been found to have a role in RNA metabolism.
\end{document}

enter image description here

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.