5

For answering the peer reviewers of a venue, one way is creating a TeX file in which you quote the reviews by putting a ">" before the lines and, then, answering your edits in simple lines.

Putting the ">" symbols at the beginning of each line, manually, is not that easy and, moreover, the lines will not be aligned, because you should go to the first of the next line, manually.

Is there any automatic way to put ">" symbols at the beginning of the entire lines of a paragraph?

hossayni
  • 225
  • You are obviously talking about an editor, but not mentioning its name. Any decent editor with regex can substitute the beggining of a line with that character s/^/>/ EDIT: Wait, scientific-workplace is the editor? – Johannes_B Jun 06 '15 at 17:38
  • @Johannes_B I am not sure if my question is about an editor because I expected a latex package solution or something like that. However, my editor is TeXstudio. – hossayni Jun 06 '15 at 17:40
  • You want to have those symbols in front of lines in the output pdf? – Johannes_B Jun 06 '15 at 17:41
  • At the beginning of each line. – hossayni Jun 06 '15 at 17:43
  • @Mico I was not aware of such software. One of the synonyms of workplace is structure by which I suppose that this tag is for scientific structures. – hossayni Jun 06 '15 at 17:55
  • Would you put this symbol at the beginning of selected lines, or of all lines of the document? – Bernard Jun 06 '15 at 19:43
  • Here is a question about formatting an email conversation, which, while different than what you ask, may provide some ideas on alternate approaches to the problem: http://tex.stackexchange.com/questions/68251/how-to-format-an-email-conversation – Steven B. Segletes Jun 07 '15 at 01:29
  • @StevenB.Segletes Thanks for the interesting link. – hossayni Jun 07 '15 at 07:57
  • (Related to @Johannes_B@'s answer.) In vim you can do this with an editing command. (To enter the command, you must be in command mode.) For example, the command :.,/^$/-1s/^/> / inserts > at the start of the current line, up to the end of the current paragraph. I'm sure you can much more sophisticated things but I only know the basics of vim and sed –  Jun 07 '15 at 10:23
  • I forgot to mention that vim lets you define keyboard macros as well, so you can execute a command by binding it to a sequence of keystrokes, e.g. a function key. –  Jun 07 '15 at 10:32

3 Answers3

10

enter image description here

\documentclass{article}
\setlength\parindent{0pt}
\setlength\parskip{\baselineskip}

\newenvironment{q}
{\bigskip
\hspace*{1em}\begin{minipage}[b]{\dimexpr\textwidth-1em}}
{\par
 \count0=\prevgraf
 \count2=\prevgraf
 \vskip-\baselineskip
 \loop
 \llap{\textgreater\space}\par
 \vskip-2\baselineskip
 \advance\count0 -1
 \ifnum\count0>0
 \repeat
 \kern\count2\baselineskip\mbox{}%
 \end{minipage}}




\begin{document}

\begin{q}One two three four \def\z{Red blue elephant giraffe green yellow monkey dog cat purple}
\z. \z\ \z. Five six seven \z.
\end{q}
Some comment on the quoted text


\end{document}
David Carlisle
  • 757,742
  • May I ask the reason for including it in a minipage? – MyUserIsThis Jun 06 '15 at 22:39
  • @MyUserIsThis a page break in the quoted paragraph would be bad, the > would all be on the second page, going up into the page head, so simplest thing is to use a minipage to avoid the problem – David Carlisle Jun 06 '15 at 23:02
  • I tried that solution here: \begin{q} \input{foo.txt} \end{q}, but didn't respect the break lines of the input text. – Adolfo Correa Nov 21 '16 at 11:50
3

The following solution also works across pages, but it still requires a bit of luck:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}

\makeatletter

\newenvironment*{threadstylequote}{%
  \par
  \dimen@ \prevdepth
  \setbox\z@ \vbox\bgroup
    \prevdepth \dimen@
    \sbox\z@{\textgreater\ }%
    \leftskip \wd\z@ \relax
    % A legal breakpoint must exist between any two lines of a paragraph:
    \ifnum\interlinepenalty<\@M\else
      \interlinepenalty 9999
    \fi
    \ifnum\clubpenalty<\@M\else
      \clubpenalty 9999
    \fi
    \ifnum\widowpenalty<\@M\else
      \widowpenalty 9999
    \fi
    % Also ensure that e-TeX extensions are not used (standard LaTeX does not 
    % use them):
    \interlinepenalties \z@
    \clubpenalties \z@
    \widowpenalties \z@
}{%
    \par
  \egroup % finish \vbox
  \splitmaxdepth \maxdepth % to be safe
  \splittopskip \z@skip
  \vfuzz \maxdimen % suppress overfull \vbox warnings
  \savingvdiscards \@ne
  \loop
    \setbox\tw@ \vsplit\z@ to\z@
    \unvbox\tw@
    \setbox\tw@ \lastbox
    \nointerlineskip
    \ifhbox\tw@
      \hbox{\rlap{\textgreater\ }\box\tw@}
    \else \ifvbox\tw@ % this should never happen...
      \box\tw@ % ... but if it does, simply reinsert the box
    \fi\fi
  \unless\ifvoid\z@
    \splitdiscards
  \repeat
}

\makeatother

\tracingpages = 1 % You can check in the log file that the club line at the end 
                  % of page 1 has been assessed at the usual penalty.

\begin{document}
\lipsum[1]
Text with some descenders: fgjpqy.
\begin{threadstylequote}
    \lipsum[2-7]
\end{threadstylequote}
\lipsum[8]
\end{document}

Output:

Output from the code

GuM
  • 21,558
  • 1
    …what do you mean by 'luck'? – Sean Allred Jun 07 '15 at 03:08
  • @SeanAllred: I just mean that the solution is not perfect: for one thing, it doesn’t fully preserve the settings for the interline penalties (although it works in standard situations). Also, if a box is followed by a mark, a whatsit, or something like this, \lastbox will not be able to remove it. – GuM Jun 07 '15 at 03:20
3

ConTeXt users can use the delimitedtext environment which is used for quotations and blockquotes. With the nextleft you can set a symbol which is shown at the left margin of each line.

\definedelimitedtext
    [thread]
    [location=paragraph,
%    indenting=no,
     left={> },
     nextleft={> }]

\setupindenting[yes,big]

\starttext

\input ward

\startthread
\input ward\par
\input ward
\stopthread

\input ward

\stoptext

A limitation of this method is that you to disable the indentation of the paragraphs because the symbol in the first line will be placed at the wrong position.

Repeated symbol at the left margin with the delimited text mechanism.

Even though one can fix this for the first line when you never have more than one paragraph there is a better solution with the help of the linenumbering mechanism. The counter for the line numbers can be hidden with the conversion=empty setting.

\definelinenumbering
    [thread]
    [conversion=empty,
     location=text,
     margin=\widthofstring{> },
     left={> }]

\setupindenting[yes,big]

\starttext

\input ward

\startlinenumbering[thread]
\input ward\par
\input ward
\stoplinenumbering

\input ward

\stoptext

Repeated symbol at the left margin with the line numbering mechanism.

Wolfgang Schuster
  • 9,400
  • 1
  • 16
  • 19