# latex commands (italic and centring ) custom command

I want to ask your assistance in two commands(in latex .tex enviroment) thie first one needs a command which is called redbold, in this command I need form the text red colour and bold style. In the second one I need a command which is called centerit. In this case I need a center align and an italic style. Only the italic style is not working for me here. I hope someone could help me in this task. Have good day, and thanking you in advance for your assistance.

Here is my code:

\documentclass{article}
\usepackage{xcolor}
\definecolor{lb}{RGB}{44, 139, 183}
\newcommand\redbold[2]{\textcolor{#1}{{\fontseries{b}\selectfont #2}}}
\newcommand\centerit[2]{{\textit{}}\centering}
\begin{document}

\redbold{red}{red and bold}
\vspace{5em}

\centerit[]{center and italic}
\end{document}


Welcome to TeX.SE. Why did you declare your \centerit command to take two arguments but used none of #1 and #2 in the replacement text? Besides, you called it with an optional (empty) argument (plus a mandatory one), but you didn't use the syntax for defining a macro that takes an optional argument (that would be \newcommand{\centerit}[numargs][default]{replacement text}).

The following should do what you want, I hope:

\documentclass{article}
\usepackage{xcolor}
\definecolor{lb}{RGB}{44, 139, 183}

\newcommand{\redbold}[2]{%
\textcolor{#1}{\fontseries{b}\selectfont #2}}

\newcommand{\centerit}[1]{%
\par\begingroup\centering\itshape #1\par\endgroup
}

\begin{document}

\redbold{red}{red and bold}
\vspace{5em}

\centerit{center and italic}

\end{document}


• Thank you! I am sorry I am not good at this topic, it as an simple course in the university and I want to complete these homework like this. Respect for your assistance. I wish happy and healthy months for you. :) – ultimate warrior Mar 27 '20 at 21:53
• Don't be sorry, I'm glad I could be of assistance... but I hope I didn't do your homework! :-p Thanks for the kind words, I wish you a good health too in these dark days! – frougon Mar 27 '20 at 22:27