1

The main question is, how can this be done with an environment? (Because I think that this would be the right way)

I want some parts to always have the same look. Have I done this right? Or should/can \newenvironment be used (if so, I don't know how). Would you generally recommend an other layout? Maybe something different than \subsection*? I thought about a table, but the descriptions of the characteristics are "very" long... .

My attempt, but I have to write characteristic1 (and so on) every time

\documentclass[preview, border={10pt}]{standalone}
\usepackage{lipsum}

\newcommand{\typ}[4]{\subsection*{typ: #1}%
\begin{description}%
\item[characteristic1] #2%
\item[characteristic2] #3%
\item[characteristic3] #4%
\end{description}}%

\newenvironment{typEnvironment}[1]%
{%
\subsection*{typ: #1}%
\description%
}%
{%
\enddescription%
}%

\begin{document}

\typ{title}{\lipsum[4]}{\lipsum[4]}{\lipsum[4]}

\begin{typEnvironment}{title}
\item[characteristic1] \lipsum[4]
\item[characteristic2] \lipsum[4]
\item[characteristic3] \lipsum[4]
\end{typEnvironment}

\end{document}
user1
  • 2,196
  • The content is imho okay, I would always prefer a list over a table if possible, but I would probably use an environment and not a command. – Ulrike Fischer Aug 17 '17 at 22:04
  • How can that be done with an environment? I only know how to set the part over and under the body, but the body itself has something to do with \item[characteristic1] #2 and so on – user1 Aug 17 '17 at 22:09
  • 2
    Well, this is something like a new list environment then, which can be defined easily with \newlist from enumitem –  Aug 17 '17 at 22:37
  • @UlrikeFischer Wondering if you would mind telling me whether \begin{} and \end{} should be avoided in definitions of environments generally? (See OP's comment on my answer.) If so, is there somewhere which explains why? – cfr Aug 18 '17 at 00:31

1 Answers1

2

Something like this?

description as enumeration

\documentclass{article}
\usepackage{enumitem,lipsum}

\newenvironment{typEnvironment}[1]%
{%
  \subsection*{typ: #1}\par
  \begin{typList}%
}%
{%
  \end{typList}%
}%
\newlist{typList}{enumerate}{1}
\setlist[typList]{label=characteristic\arabic*,font=\bfseries,wide,align=left,labelindent=0pt}
\begin{document}
\begin{typEnvironment}{title}
  \item \lipsum[4]
  \item \lipsum[4]
  \item \lipsum[4]
\end{typEnvironment}
\end{document}
cfr
  • 198,882
  • Normally something like \typListand \endtypListshould be used inside the environment-definition, am I right? And I guess the package enumitem doesn't provide this by default? – user1 Aug 18 '17 at 00:12
  • @Ben I'm not sure. Why should that be used? There are some cases where you can't use the \begin{} \end{} syntax inside, but I wasn't aware that it is a general rule. Do you have a reference? – cfr Aug 18 '17 at 00:28
  • I read that on StackExchange, but no idea where. Something like "Do not use several scopes, if not needed" – user1 Aug 18 '17 at 11:24
  • 1
    I'm referencing to the second paragraph of this answer. – user1 Aug 18 '17 at 11:31
  • @Ben I'm not sure about that advice generally, but here you do want an additional group for the list, because the list is distinct from the sectioning command. However, you could use the \typList ... \endtypList if you prefer. Really, I don't know. It might be worth asking as a separate question, if it hasn't been asked already. If you don't ask, maybe I will. (If you do ask it, can you put a link here in the comments, so I don't duplicate it?) – cfr Aug 18 '17 at 17:28
  • I actually now see that this is not what I wanted :D The characteristic1 (and so on) were only placeholders. Indeed there is always a different text (but in every typEnvironment there are always the same three items). As I scanned the manual, there is no way to do this). I would also remove the labelindent=0pt. There is no need that you try to aim this. – user1 Aug 21 '17 at 15:09
  • @Ben It might be best to ask a new question, with an example showing what you want and a link to your question here as background, so people can access the ideas and problems discussed here. Maybe you just want a description? But I don't really know what you mean by its always being a different text but always the same three items. So try to make this clear with the example you give in your new question. – cfr Aug 22 '17 at 02:13