2

I've made a new environment to do commented lists, an adapted itemize without symbols:

\documentclass{report}
\usepackage{mathtools}
\newenvironment{clist}
    {\newcommand\com[2][1cm]{\par{\small\rule{##1}{0pt}\parbox{\linewidth-##1}{##2}}\par}\renewcommand\labelitemi{}\begin{itemize}}
    {\end{itemize}}
\begin{document}
\begin{clist}
  \item First thing
  \item Second thing
    \com{This thing was good!}
  \item Last thing
\end{clist}
\end{document}  

i.e. \small comment paragraphs with default 1cm indent, optional \com param sets indent size.

My question is - How can I make \com like \item in not needing brackets? So that I can write the comment paragraphs

\com Like this?

I don't really care if there's a package that can do this easily; I'd like to be able to customize this sort of thing in various ways, and understand how to do so, not necessarily with itemize or lists if some other way's easier. Or maybe it's just too tricky to be worth bothering about.

5
  • Welcome to TeX.SX! Can you please expand the code snippets that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a \documentclass command, include any necessary packages and be as small as possible to demonstrate your problem.
    – user30471
    Mar 26, 2018 at 8:46
  • 1
    It is hard to do in general (\item never needs to grab its argument, it just affects the paragraph settings) so if you know you just want to grab to the end of the first paragraph, or grab to the next \item or \end it's possible, but detecting the next \end is a pain as you need to step over nested \begin..\end "by hand" so it's not impossible (I expect that code doing it is on this site already) but it is rather fragile and TeX doesn't help make such an interface. Mar 26, 2018 at 11:52
  • @Adam Ponting Are you ok with my answer ?
    – Tarass
    Mar 27, 2018 at 11:24
  • @DavidCarlisle Thanks! Very helpful. (Is there another .sx site with so many legends of the field so active?! It's amazing. Maybe that's something to do with the friendly vibe here.) Mar 28, 2018 at 6:39
  • @Tarass Hi. (I don't know if it's usual to accept an answer after just 1 day.) I wanted the comment to be in an indented paragraph, I should have ipsum-ed a comment paragraph to make that more obvious I guess. It seems having an indented comment paragraph is impossible with your method, no? Maybe in your answer you could explain a little how it works? Well, I've started learning TeX so I can understand it. hehe thanks. Mar 28, 2018 at 6:39

2 Answers 2

1

enter image description here

\documentclass{article}
\pagestyle{empty}
\usepackage{paralist,lipsum}

\newcommand{\Com}[1][4]{%
    \xdef\MySkip{\leftskip#1em}%
    \item[\aftergroup\MySkip\aftergroup\footnotesize]}
\makeatletter

\newcommand{\savefont}{%
    \xdef\oldfontsize{\f@size}%
    \xdef\oldblskip{\f@baselineskip}}

\newcommand{\backtoppevfont}{%
     \fontsize{\oldfontsize}{\oldblskip}\selectfont}

\makeatother

% Take one optional argument
% item caracter ex $\bullet$
\newenvironment{Itemize}[1][]{%
    \savefont%
    \def\FntSz{\fontsize{\MyL}{\MyL}\selectfont}%
    \begin{list}{%
        \xdef\MySkipBack{\leftskip0em}%
        \backtoppevfont#1\aftergroup\backtoppevfont\aftergroup\MySkipBack}{%
        \setlength{\labelwidth}{0em} % adapt as you want
        \setlength{\leftmargin}{0pt}
        \setlength{\itemindent}{\parindent} % indentation here
    }}{%
    \end{list}}


\begin{document}

\lipsum[1]

Let's make an list :

\begin{Itemize}
\item \lipsum[2]
\addtolength{\parindent}{10pt}
\Com \lipsum[3]
\item Two
\item Three
\Com This is my comment
\end{Itemize}

\end{document}
7
  • 1
    If you want to make a newcommand with it, you allways can do: \newcommand{\Com}[1][\hspace{2em}]{\item[#1]}.
    – Tarass
    Mar 26, 2018 at 12:46
  • Thank your your remark. Is that better ?
    – Tarass
    Mar 26, 2018 at 13:37
  • @DavidCarlisle is this better and not too fragile ?
    – Tarass
    Mar 26, 2018 at 20:24
  • Oh it's bound to be fragile but much better thanks (+1:-) Mar 26, 2018 at 20:47
  • @DavidCarlisle To learn something, could give me an example where it is fragile, if it is not to compicate ?
    – Tarass
    Mar 26, 2018 at 20:50
0

As David C said, grabbing to the end of the first paragraph isn't too hard. Here's a version that does that. It relies on a blank line (new para) following each comment.

\documentclass{report}
\usepackage{mathtools}
\newenvironment{clist}
   {\renewcommand\labelitemi{}\def\com##1\par{\par\rule{2em}{0pt}\parbox{%  
\linewidth-2em}{\small##1}}\begin{itemize}} 
    {\end{itemize}}
\begin{document}
\begin{clist}
  \item First thing
  \item Second thing 
    \com This thing was good! This thing was good! This thing was good! This  
thing was good! This thing was good! This thing was good! 

  \item Last thing
\end{clist}
\end{document}

(This won't cause problems if you don't have an existing command called \com...)

TeX macro parameters 101: The first \par delimits \com's parameter; that is, TeX looks for \par in the comment - a new paragraph/an empty line in LaTeX code - to know when the parameter ends. It can be replaced by other things. If replaced by a full stop - \def\com##1. - then the new paragraphs/blank lines aren't needed and comments just need a . to end them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .