add tag
Anonymous 1123
I am trying draw a regular prisms. I tried
```
\documentclass[border=2mm,tikz]{standalone} 
\usetikzlibrary{calc,3dtools, intersections}%
%\usepackage{tikz-3dplot}

\begin{document}
	\begin{tikzpicture}[line cap=round,line join=round]
		\begin{scope}[3d/install view={phi=110,theta=70},
			declare function={R=3;% radius of the base 
				H=5;% height of S
			% height of the intersecting plane
			},
			dot/.style={circle,fill,inner sep=1.2pt,label=above:{#1}}]
			\pgfmathtruncatemacro{\Ncorners}{7}	
			\path 
			(0,0,0) coordinate (O) 	
			(0,0,H) coordinate (S) 
			(0,0,H/2) coordinate (C) 		
			foreach \X in {1,...,\Ncorners}
			{({R*cos(\X*360/\Ncorners)},{R*sin(\X*360/\Ncorners)},0) 
				coordinate (A\X)
			}
		foreach \X in {1,...,\Ncorners}
	{({R*cos(\X*360/\Ncorners)},{R*sin(\X*360/\Ncorners)},H) coordinate (A'\X)
	}	;
			\path foreach \X in {1,...,\Ncorners}{(A\X) node[dot={$A_\X$}]{}
				{}} 
			foreach \X in {1,...,\Ncorners}{(A'\X) node[dot={$A'_\X$}]{}
				{}} ;
			\foreach \X [remember=\X as \LastX (initially \Ncorners)] in {1,...,\Ncorners} 
	{			\tikzset{3d/polyhedron/.cd,O={(C)},fore/.append style={fill=none},
			back/.append style={3d/hidden},
					fore/.append style={3d/visible,fill=none},
					draw face with corners/.expanded={{(A\LastX)},{(A'\LastX)},{(A'\X)},(A\X)}}
			}
		\end{scope}
	\end{tikzpicture}
\end{document}    
```

I only get

![ScreenHunter 116.png](/image?hash=a03468720b8d3251498838fb230715eba58079c6e4302ebe15a36a718ff67dfa)

My questions:
1. How to correct it?
2. How to label with corners as `A, B, C, ..., ` instead of `A_1, A_2, ...,`?
Top Answer
marmot
The reason why there are dashed lines on the top is that you do not draw the polygon on the top. As for the alphabetic numbering, `foreach` understands alphabetical sequences. (Why LaTeX decided to "hide" the `\@Alph` command from the general public I don't know, but we can use it invoking `\makeatletter` and `\makeatother`.) Building up the list of vertices is straightforward with the `/.list` key handler:
```
\edef\mycorners{{(A')}}		
\tikzset{add corner/.code={\edef\mycorners{\mycorners,{(#1')}}},
	add corner/.list={B,...,\myLetter}}		
```
All these things combined give
```
\documentclass[border=2mm,tikz]{standalone} 
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
  \begin{scope}[3d/install view={phi=110,theta=70},
		declare function={R=3;% radius of the base 
			H=5;% height of S
		% height of the intersecting plane
		},
		Dot/.style 2 args={circle,fill,inner sep=1.2pt,label=#1:{#2}},
		dot/.style={Dot={below}{#1}},dot'/.style={Dot={above}{#1}}]
	\pgfmathtruncatemacro{\Ncorners}{7}	
	\makeatletter
	\edef\myLetter{\@Alph{\Ncorners}}
	\makeatother	
	\path 
		(0,0,0) coordinate (O) 	
		(0,0,H) coordinate (S) 
		(0,0,H/2) coordinate (CC) 		
		foreach \X [count=\Y] in {A,...,\myLetter}
		{({R*cos(\Y*360/\Ncorners)},{R*sin(\Y*360/\Ncorners)},0) 
			coordinate (\X)
		({R*cos(\Y*360/\Ncorners)},{R*sin(\Y*360/\Ncorners)},H) 
		coordinate (\X')
		};
	\path foreach \X in {A,...,\myLetter}{
	(\X) node[dot={$\X$}]{} (\X') node[dot'={$\X'$}]{}};
	\edef\mycorners{{(A')}}		
	\tikzset{add corner/.code={\edef\mycorners{\mycorners,{(#1')}}},
		add corner/.list={B,...,\myLetter}}		
	\begin{scope}[3d/polyhedron/.cd,O={(CC)},fore/.append style={fill=none},
		back/.append style={3d/hidden},
		fore/.append style={3d/visible,fill=none},
		edges have complete dashes]
		\foreach \X [remember=\X as \LastX (initially \myLetter)] 
		in {A,...,\myLetter} 
		{\tikzset{3d/polyhedron/draw face with
		corners/.expanded={{(\LastX)},{(\LastX')},{(\X')},(\X)}}}
		\tikzset{3d/polyhedron/draw face with corners/.expanded={\mycorners}}
    \end{scope} 		
  \end{scope}
\end{tikzpicture}
\end{document}  
```
![Screen Shot 2021-04-28 at 10.47.39 AM.png](/image?hash=e439078822f8ae374fcf60fed292a97c43401ebb2de430eb6df9881996e08331)

If you want to wrap this in a loop, a few precautions are necessary.
```
\documentclass[border=2mm,tikz]{standalone} 
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\makeatletter
\tikzset{Dot/.style 2 args={circle,fill,inner sep=1.2pt,label=#1:{#2}},
		dot/.style={Dot={below}{#1}},dot'/.style={Dot={above}{#1}},
		add corner/.code={\edef\mycorners{\mycorners,{(#1')}}},
		Alpha/.code 2 args={\edef#1{\@Alph{#2}}}}
\makeatother	
\begin{document}
\foreach \Ncorners in {3,...,12}
{\begin{tikzpicture}[line cap=round,line join=round,same bounding box=A]
  \begin{scope}[3d/install view={phi=110,theta=70},
		declare function={R=3;% radius of the base 
			H=5;% height of S
		% height of the intersecting plane
		},Alpha={\myLetter}{\Ncorners},		
		]

	\path 
		(0,0,0) coordinate (O) 	
		(0,0,H) coordinate (S) 
		(0,0,H/2) coordinate (CC) 		
		foreach \X [count=\Y] in {A,...,\myLetter}
		{({R*cos(\Y*360/\Ncorners)},{R*sin(\Y*360/\Ncorners)},0) 
			coordinate (\X)
		({R*cos(\Y*360/\Ncorners)},{R*sin(\Y*360/\Ncorners)},H) 
		coordinate (\X')};
	\path foreach \X in {A,...,\myLetter}{
	(\X) node[dot={$\X$}]{} (\X') node[dot'={$\X'$}]{}};
	\edef\mycorners{{(A')}}		
	\tikzset{add corner/.list={B,...,\myLetter}}		
	\begin{scope}[3d/polyhedron/.cd,O={(CC)},fore/.append style={fill=none},
		back/.append style={3d/hidden},
		fore/.append style={3d/visible,fill=none},
		edges have complete dashes]
		\foreach \X [remember=\X as \LastX (initially \myLetter)] 
		in {A,...,\myLetter} 
		{\tikzset{3d/polyhedron/draw face with
		corners/.expanded={{(\LastX)},{(\LastX')},{(\X')},(\X)}}}
		\tikzset{3d/polyhedron/draw face with corners/.expanded={\mycorners}}
    \end{scope} 		
  \end{scope}
\end{tikzpicture}}
\end{document} 
```
![ani.gif](/image?hash=16a8bb260c2e9e55d9f4fd0ef2db7a5951b62ae357db2faafb4fd8ec991e2516)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.