I am writing a latex document and while writing a commutative diagram using the tikz environment, the width of the compiled diagram is beyond the width of the rest of the text. Here's the code:

% these two slashes-commands for continuous chapter numbering in parts of the document
\titleformat{\chapter}{\normalfont\huge}{\thechapter.}{20pt}{\huge\bf} %for chapter headings
\usepackage{tikz-cd} % and in the above line to use commutative diagrams
% below four lines to just one or two cyrillic letter
 %Cyrillic letter command over
\usepackage[toc]{appendix} % to make appendi appear in the table of contents
 \usepackage{amssymb}  %to use direct sum symbol
 \usepackage{graphicx} %toinsert images
 \usepackage{amsmath} %to use matrices
 \usepackage{bm} % to use bold font in math mode use \bm{ insert math mode text}
 \usepackage{mathrsfs} %for scripted english characters
 \usepackage{tikz-cd} % to draw commutative diagrams

All this can be combined in the following:
  0 \arrow{r} & 
\frac{E'(K)}{\phi(E(K))} \arrow{r}{\delta} \arrow{d} &
H^{1}(G_K, E[\phi]) \arrow{r} \arrow{d}{Res_v} &
WC(E/K)[\phi] \arrow{r} \arrow{d} & 0 \\
0 \arrow{r} &
\frac{E'(K_v)}{\phi(E(K_v))} \arrow{r}{\delta_{v}} \arrow{d} &
H^{1}(G_{v}, E[\phi]) \arrow{r} \arrow{d} & 
WC(E/K_{v})[\phi] \arrow{r} \arrow{d} & 0 \\
0 \arrow{r} & 
\prod\limits_{v \in M_K} \frac{E'(K_v)}{\phi(E(K_v))} \arrow{r}{\prod\limits_{v \in M_K}\delta_{v}} &
\prod\limits_{v \in M_K} H^{1}(G_{v}, E[\phi]) \arrow{r} &
\prod\limits_{v \in M_K} WC(E/K_{v})[\phi] \arrow{r} & 0 

It would be great if someone could help me in this. Thank you so much.

1 Answer 1


To fit your diagram in text width you should take two measured:

  • reduce distance between nodes
  • use smaller font
  • use \mathclap from the mathtools package for writing limits of products:

%---------------- show page layout. don't use in a real document!

    \begin{tikzcd}[sep=1.8em, font=\small]
0 \ar{r} & \frac{E'(K)}{\phi(E(K))} \ar{r}{\delta} \ar{d} 
    & H^{1}(G_K, E[\phi]) \ar{r} \ar{d}{Res_v} & WC(E/K)[\phi] \ar{r} \ar{d} & 0 \\
0 \ar{r} & \frac{E'(K_v)}{\phi(E(K_v))} \ar{r}{\delta_{v}} \ar{d} 
    & H^{1}(G_{v}, E[\phi]) \ar{r} \ar{d} & WC(E/K_{v})[\phi] \ar{r} \ar{d} & 0 \\
0 \ar{r} & \prod\limits_{\mathclap{v \in M_K}} \frac{E'(K_v)}{\phi(E(K_v))} 
            \ar{r}{\prod\limits_{\mathclap{v \in M_K}}\delta_{v}} 
\prod\limits_{\mathclap{v \in M_K}} H^{1}(G_{v}, E[\phi]) \ar{r} &
\prod\limits_{\mathclap{v \in M_K}} WC(E/K_{v})[\phi] \ar{r} & 0

enter image description here

  • I am getting the following error: Package pgfkeys error on using the above code. More details: ! Package pgfkeys Error: I do not know the key '/tikz/sep' and I am going to ig nore it. Perhaps you misspelled it. See the pgfkeys package documentation for explanation. Type H <return> for immediate help.
    – Shreya
    Apr 18, 2020 at 4:18
  • I removed 'sep=1.8em' from your code and the rest of the it is working perfectly, the only difference is that the tag $**$ is right below the diagram instead of on the right side to it. But that's not a big problem. Thank you again!
    – Shreya
    Apr 18, 2020 at 4:34
  • 1
    @Shreya, I select sep=1.8em that tag (**) can be inline with diagram. MWE is tested with recent MIkTeX installation. If you use Overleaf then can happen that there are older version of packages which doesn't work as expected. Try to use column sep instead of sep.
    – Zarko
    Apr 18, 2020 at 4:41
  • I am using a really old installation of TeXmaker with TexLive. And what you suggested is still not working though. I appreciate the help though. Thanks~
    – Shreya
    Apr 18, 2020 at 4:47
  • 1
    @Shreya, try to update your LaTeX installation. As far as I read in site, now is available version TexLive 2020.
    – Zarko
    Apr 18, 2020 at 4:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .