# how to shift the downarrows toward little bit right side?

How to draw the following diagram in Tikz-pgf?

Also in the current code, how to shift the downarrows toward little bit right side. I want the downarrows just down A and above A' and the function f_1 at the right or left and so on for others. In the current graph the downarrows are placed toward little bit left side.

I have used the following code to get above graph:

\begin{align}
\matrix{
A&\longrightarrow&B &\longrightarrow&C&\longrightarrow&D&\longrightarrow&E
\cr \downarrow f_1&&\downarrow f_2&&\downarrow f_3&&\downarrow f_4&& \downarrow f_5
\cr A' &\longrightarrow&B'&\longrightarrow& C' &\longrightarrow& D'&\longrightarrow&E'}
\end{align}


Please help me to fix the above code without using Tikz-CD

• Better is to use tikz-cd package than pure tikz and its matrix library. Jan 30 at 10:48
• @Zarko, can you leave a answer please in tikz-cd? Jan 30 at 10:56
• Done! See answer below. Jan 30 at 11:04
• @Zarko, I tried but couldn't add Tikz-CD through MikTex Admin update.It is asking local repository file and I am selecting the Tikz-CD file where I kept it, but is saying, not found. That is why I thought to keep the above code of mine. But I need to fix the downarrows to make straight connection between the up and down objects and to place the maps f_i to the right or left as in your picture. Can you help to fix it ? Jan 30 at 13:29

\documentclass[margin=3.1415692mm,varwidth]{standalone}
\usepackage{tikz-cd}

\begin{document}
$$\begin{tikzcd}[row sep=huge, baseline=3ex] A \ar[r] \ar[d,"f_1"] & B \ar[r] \ar[d,"f_2"] & C \ar[r] \ar[d,"f_3"] & D \ar[r] \ar[d,"f_4"] & E \ar[d,"f_5"] \\ A' \ar[r] & B' \ar[r] & C' \ar[r] & D' \ar[r] & E' \\ \end{tikzcd}$$
\end{document}


for details of tikz-cd, which is based on TikZ matrix library, see its documentation. It is part of your LaTeX installation or you can find on CTAN .

Edit: Corrected is error in functions indices

• Thanks. Beautiful. Jan 30 at 11:12
• @M.A.SARKAR, you are welcome. Now I see, thatI I forgot on prime symbols in the second row of diagram Corrected now. Jan 30 at 11:16
• I think my Latex editor has no such package.It is saying i do not know '/tikz/r', You provided a link. I downloaded it. Can you tell me how to implement it with my latex editor ? Jan 30 at 11:25
• @M.A.SARKA, editor haven't any package, they are part of your LaTeX installation. Check if tikz-cd is installed or simple use vizard of your LaTeX installation and load it. Which LaTeX distribution you use= Jan 30 at 11:30
• @Sebastiano, you are right ... apparently I employ copy-past dwarf ;-). I will corrected ASAP Mar 16 at 21:22

Surely also with xy package it is possible to realize your desidered output:

\documentclass[12pt]{article}

\usepackage[all,cmtip]{xy}
\begin{document}
\xymatrix@R=2.5pc{
A \ar[d]^{f_1} \ar[r] & B \ar[d]^{f_2}  \ar[r] &  C \ar[d]^{f_3} \ar[r]  & D \ar[d]^{f_4} \ar[r] & E \ar[d]^{f_5}\\
A' \ar[r] & B'  \ar[r] & C'  \ar[r] & D' \ar[r] & E'}

\xymatrix@R=2.5pc@C=2.5pc{
A \ar[d]^{f_1} \ar[r] & B \ar[d]^{f_2}  \ar[r] &  C \ar[d]^{f_3} \ar[r]  & D \ar[d]^{f_4} \ar[r] & E \ar[d]^{f_5}\\
A' \ar[r] & B'  \ar[r] & C'  \ar[r] & D' \ar[r] & E'}

\end{document}


PS: With @R=2.5pc@C=2.5pc (R=row; C`=column) you can change the dimension of the matrix.

• +1: Looks good! Mar 16 at 22:36
• @Dr.ManuelKuehner Thank you so much from the bottom of my heart.... Mar 16 at 22:42
• @Sebastiano, It is really a nice answer. It worked fine in latex editor. Thanks Mar 17 at 6:53
• @M.A.SARKAR :-)) Thank you very much for your feedback. Mar 18 at 21:45