I'm here again. Here's the thing:
I found a large number of wonderful examples of TikZ-graph on texexample.net. While I nothing relevant to protein except for a DNA genome double helix in TikZ. So I hope to modify it to a alpha helix like follows:
And here are my MWE:
\documentclass{book}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\tikzset{helix part/.style n args={2}{insert path={
plot[smooth,variable=\x,domain=-90+#1*180:90+#1*180,
samples=11] ({\pgfkeysvalueof{/tikz/helix/radius}*cos(\x)},
{\x*(\pgfkeysvalueof{/tikz/helix/stretch}*\pgfkeysvalueof{/tikz/helix/radius}/360)+#2},{-\pgfkeysvalueof{/tikz/helix/radius}*sin(\x)})
-- plot[smooth,variable=\x,domain=90+#1*180:-90+#1*180,
samples=11]
({\pgfkeysvalueof{/tikz/helix/radius}*cos(\x)},
{\x*(\pgfkeysvalueof{/tikz/helix/stretch}*\pgfkeysvalueof{/tikz/helix/radius}/360)+\pgfkeysvalueof{/tikz/helix/width}+#2},{-\pgfkeysvalueof{/tikz/helix/radius}*sin(\x)})
}},helix/.is family,
helix/.cd,
radius/.initial=3,stretch/.initial=3,width/.initial=1.5}
\tdplotsetmaincoords{90}{105}
\newcommand{\myprotein}[1]{%
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[scale=.1]
rectangle (20,1.1*\pgfkeysvalueof{/tikz/helix/radius});
\foreach \X in {0,2,...,8}
{
\path[top color=#1!60!black,bottom color=#1!30,middle color=#1,
helix part={\X}{0}];
}
\foreach \X in {1,3,...,9}
{
\path[top color=#1!30,bottom color=#1!60!black,middle color=#1,
helix part={\X}{0}];
}
\end{scope}
\end{tikzpicture}
}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
\begin{tikzpicture}
\fill (0,0) ellipse (2 and 1);
\myprotein{olive}
\end{tikzpicture}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST
\end{document}
I found the structure was terrible just like this:
However, the structure returned to normal when I annotated the code \myprotein{olive} which was relevanted to tikz-3dplot.
So, I wonder is there any clash between tikz-3dplot and text part?




tikzpictures. Most likely this is the reason for your problems. – Dec 22 '20 at 05:18