5

MWE:

\documentclass[journal,twoside]{IEEEtran}
\usepackage{color}

\usepackage{amsmath} 
\begin{document}
\textcolor{red}{
\IEEEPARstart{L}orem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur elit lectus, lobortis at eros tincidunt, viverra cursus augue.}
\end{document}

Result without \textcolor

Without <code>\textcolor</code>

Result with \textcolor

With <code>\textcolor</code>

Explanation & Questions:

As you may notice, normally the \IEEEPARstart letter will be aligned with the text, however, when the latter command is "affected" by the command \textcolor the letter will no longer be aligned, it will be out of margin.

  • The first question, and please, if you are going to post an answer to this question, be sure to answer this and not only give a solution. Why does this happen?
  • What is the solution to obtain colored text and aligned \IEEEPARstart letter?
  • 2
    \textcolor uses a group of its own and messes with the grouping in the definition of \IEEEPARstart. Try \color{red} \IEEEPARstart{L}{orem} ............. and then for black text put \color{black} text follows. – user11232 Sep 1 '15 at 15:56
  • 1
    I think that it works, could you posted as an answer?, please, and one more thing, are you sure it doesn't affect anything else (the \color{}red)? I'll see if I find any errors and tell you about it. And one more thing, do you know what is exactly the grouping definition that it's being changed? (Like to fix it in case I need to use specifically \textcolor) – Hans Sep 1 '15 at 16:40
  • 1
    @HarishKumar What if I had a different color before?, is there a way of saving the current color (like in a variable) each time before \color{somecolor} and then recall it? – Hans Sep 4 '15 at 12:57
3

For all sorts of reasons it's best to start and end colour in horizontal mode, so I'd use \textcolor rather than \color also note that \IEEEPARstart takes two arguments not one, the intended usage is \IEEEPARstart{L}{orem} not \IEEEPARstart{L}.

Even though it means specifying the colour in more than one place I'd do the following, using a protected command to hide the colour name from the uppercasing which is applied to the second argument of \IEEEPARstart.

enter image description here

\documentclass[journal,twoside]{IEEEtran}
\usepackage{color}
\DeclareRobustCommand\red{\textcolor{red}}
\usepackage{amsmath} 
\begin{document}

\IEEEPARstart{\red{L}}{\red{orem}} \red{ipsum dolor sit amet,
  consectetur adipiscing elit. Curabitur elit lectus, lobortis at eros
  tincidunt, viverra cursus augue.}
\end{document}

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.