# How to write the perfect codes for expression in latex as in the first figure?

For this expression I have written :

\begin{enumerate}
\item $\langle \varphi _{ij},\rho _{kl} = 0$;
\item  $\langle \varphi _{ij},\rho _{kl} \rangle = \begin{cases} \frac{1}{n}& \text{if } i=k,j=l\\ 0 & \text{otherwise} \end{cases}$
\end{enumerate}


But it shows (in pdf)...

How I will make it perfect? Thanks!

• Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – user36296 Jan 15 at 15:41
• Can you edit your title to say what your question is about? This way it would be much more helpful to future users with the same problem than such a generic title. – user36296 Jan 15 at 15:44
• You could try changing otherwise to else. without our help. And add a \rangle after \rho_{kl} in the first item. Other than these, what are you unhappy about? – Benjamin McKay Jan 15 at 16:10
• See e.g. here. – Circumscribe Jan 15 at 16:21
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Jan 16 at 15:38

I'd simply use $...$ as for the first item, and a medium-sized fraction from nccmath:

\documentclass{article}

\usepackage{nccmath, makebox}

\begin{document}

\begin{enumerate}
\item $\langle \varphi _{ij},\rho _{kl}\rangle = 0$\,;
\item $\langle \varphi _{ij},\rho _{kl} \rangle = \begin{cases} \makebox*{0}{$ \mfrac{1}{n} $}& \text{if } i=k,\:j=l \\[1ex] 0 & \text{otherwise} \end{cases}$
\end{enumerate}

\end{document}


• The vertical (non)alignment of the 1/n and 0 looks ugly, though. In the OP's first image "1/n" is left-aligned with the "0." Personally I would leave it like that - just because you can do fractions in LaTeX math doesn't mean you always should. – alephzero Jan 15 at 16:19
• @alephzero: You're right. How about the modified version? – Bernard Jan 15 at 16:30