2

I have the following code:

\begindc{\commdiag}[500]
\obj(0,0){$k(s)$} 
\obj(0,2){$K$}
\obj(-1,1){$k(x)$}
\obj(1,1){$k(y)$}
\mor(0,0)(-1,1){}[+1,6]
\mor(0,0)(1,1){}[-1,6]
\mor(-1,1)(0,2){}[+1,6]
\mor(1,1)(0,2){}[+1,6]
\enddc

I want to put \spec inside every object.

I already defined \spec in beginning of my document as,

\DeclareMathOperator\spec{spec}

But I get error when I do it inside the commutative diagram.

  • Is your question answered by one of the posts? If not, please edit your question. If yes, please accept one answer here by clicking the check mark to its left and I will delete my comment here. Thank you. – LaRiFaRi May 3 '16 at 11:45
3

May I recommend to use the more modern package ? This would look like this:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mathtools}
\DeclareMathOperator\spec{spec}

\begin{document}
\[
\begin{tikzcd}[every arrow/.append style={hook}]
& \spec K & \\
\spec K(x)\arrow{ur} & & \spec K(y)\arrow{ul} \\
& \spec k(s)\arrow{ur}\arrow{ul} &
\end{tikzcd}
\]
\end{document}

enter image description here


If you want to stick to dcpic, you may use the starred version of \DeclareMathOperator as a workaround.

% arara: pdflatex

\documentclass{article}
\usepackage{pictexwd,dcpic}
\usepackage{mathtools}
\DeclareMathOperator*\spec{spec} % Asterisk added

\begin{document}
\begindc{\commdiag}[500]
\obj(0,0){$\spec k(s)$} 
\obj(0,2){$\spec K$}
\obj(-1,1){$\spec k(x)$}
\obj(1,1){$\spec k(y)$}
\mor(0,0)(-1,1){}[+1,6]
\mor(0,0)(1,1){}[-1,6]
\mor(-1,1)(0,2){}[+1,6]
\mor(1,1)(0,2){}[+1,6]
\enddc
\end{document}

enter image description here

  • Neither the normal form nor the starred form initiate display math. The error is much subtler and using the star form is not the solution. – egreg Jun 23 '15 at 8:32
  • @egreg thanks, I remove that paragraph and hope for an answer from you. – LaRiFaRi Jun 23 '15 at 8:43
  • Investigating; it surely has to do with the fact that \nolimits@ looks ahead in order to kill a \limits token. – egreg Jun 23 '15 at 8:55
1

It's a bug in dcpic, which uses \edef instead of \protected@edef:

\documentclass{article}
\usepackage{amsmath}
\usepackage{dcpic,pictexwd}
\DeclareMathOperator\spec{spec}

\makeatletter
\@namedef{!coloca}#1#2{\protected@edef\pilha{#1.#2}} % had \edef
\makeatother

\begin{document}
\begindc{\commdiag}[500]
\obj(0,0){$\spec k(s)$}
\obj(0,2){$\spec K$}
\obj(-1,1){$\spec k(x)$}
\obj(1,1){$\spec k(y)$}
\mor(0,0)(-1,1){}[+1,6]
\mor(0,0)(1,1){}[-1,6]
\mor(-1,1)(0,2){}[+1,6]
\mor(1,1)(0,2){}[+1,6]
\enddc
\end{document}

enter image description here

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.