0

I came across the a paper where the STL file format was depicted in the following way.

STL file format

I would very much be interested in using something similar to this but I have no clue how to achieve this.

  • Welcome to tex.se. By "use", do you mean read an STL file (e.g., into Asymptote, https://tex.stackexchange.com/questions/282106/render-stl-files-in-asymptote), or producing one given a structure? – Cicada Apr 21 '21 at 13:51

2 Answers2

0

Manual solution using a tabular surrounded by curly braces (based on Curly brackets spanning multiple lines (no math env)):

\documentclass{article}
\begin{document}
\noindent\textbf{solid} \textit{name}\\
$\left\{
\begin{tabular}{@{}l@{}}
    \textbf{facet normal} $n_i n_j n_k$ \\
    \hspace{1em}\textbf{outer loop} \\
    \hspace{2em}\textbf{vertex} $v1_x\ v1_y\ v1_z$\\
    \hspace{2em}\textbf{vertex} $v2_x\ v2_y\ v2_z$\\
    \hspace{2em}\textbf{vertex} $v3_x\ v3_y\ v3_z$\\
    \hspace{1em}\textbf{endloop}\\
    \textbf{endfacet}
\end{tabular}
\right\}^+$\\
\textbf{endsolid} \textit{name}
\end{document}
Marijn
  • 37,699
0

I'd define an environment that builds a single block with a tabular and the inner part with a nested tabular.

\documentclass{article}

\NewDocumentEnvironment{stl}{t+mm} {% #1 = optional +, #2 = key, #3 = name \renewcommand{>}{\quad\ignorespaces} % use > to `advance' \begin{tabular}{@{}l@{}} \stlkey{#2} \textit{#3} \ $\left\lbrace\begin{tabular}{@{}l@{}} } {% \end{tabular}\right\rbrace\IfBooleanT{#1}{^+}$ \ \stlkey{end#2} \textit{#3} \end{tabular} } \NewDocumentCommand{\stlkey}{m}{\textbf{#1}}

\begin{document}

\begin{stl}+{solid}{name} \stlkey{facet normal} $n_i n_j n_k$ \ > \stlkey{outer loop} \ >> \stlkey{vertex} $v1_x\ v1_y\ v1_z$\ >> \stlkey{vertex} $v2_x\ v2_y\ v2_z$\ >> \stlkey{vertex} $v3_x\ v3_y\ v3_z$\ > \stlkey{endloop}\ \stlkey{endfacet} \end{stl}

\end{document}

You'll need \usepackage{xparse} if running LaTeX released prior to 2020-10-01.

The superscript + is only added if you specify it as indicated in the code above. With \begin{stl}{solid}{name} the superscript + will not be printed.

The \> command is slightly abused, but it seems an easy way to indent the code as wished.

enter image description here

egreg
  • 1,121,712