3

In Lyx I would like to convert greyed out text into comments. The Lyx environment is lyxgreyedout. I have considered switching to another IDE already and it is not an acceptable solution.

The website below does something similar I think but I don't quite follow it: http://www.mail-archive.com/lyx-users@lists.lyx.org/msg79368.html

If there is some alternate way of allowing comments to show up in a draft but not the final product in Lyx, please let me know.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
denilw
  • 3,156
  • Could you make clear in your question what you want to achieve. It isn't obvious why the "lyx" tag is relevant here, but given your comment on Martin's answer, I expect it might be. – Seamus Mar 30 '11 at 22:26

3 Answers3

3

Use the comment package and then \excludecomment{gray} to redefine the gray environment to be ignored.

Example:

\documentclass{article}
\usepackage{xcolor}
\newenvironment{gray}{\color{gray}}{}
\usepackage{comment}
\excludecomment{gray}

\begin{document}

...
\begin{gray}
    Text
\end{gray}
...

\end{document}

There is also \includecomment{<env>} to define an environment which is simply included. See my answer to Is it possible to keep my translation together with original text? for an example.

Martin Scharrer
  • 262,582
  • +1 this seems like a great solution. Ultimately I want to use this for the to redefine the lyx command \lyxgreyedout, however \excludecomment{lyxgreyedout} doesn't work. I have rolledback the title change in the hopes that a solution to the more general case of redefining an environment will work. – denilw Mar 30 '11 at 21:52
  • @denilw: Please mention the Lyx application in your question and add the {lyx} tag as well. Your question doesn't has much to do with redefining an environment in general (which is done using \renewenvironment BTW), which was the reason I changed the title. – Martin Scharrer Mar 30 '11 at 22:05
  • 1
    I added the lyx tag, though I have had bad success getting help whenever I mention lyx. No one takes the question seriously. Most of the time the first answer is don't use lyx. – denilw Mar 30 '11 at 22:18
  • @denilw: I see. What is the problem of using \excludecomment{lyxgreyedout}? The expression doesn't work doesn't tell me much. – Martin Scharrer Mar 30 '11 at 22:20
  • 1
    Lyx has a predefined environment for lyxgreyout. When I add \excludecomment{lyxgreyedout} to the preamble of the document, I get many errors saying Extra }, or forgotten \endgroup and a short description of where the error occurs says \end{lyxgreyedout}. I find that it is possible to convince lyx to do what you want but when overriding it's default behavior I get these kinds of errors sometimes. – denilw Mar 30 '11 at 22:28
  • that said I don't know what to do in this specific case – denilw Mar 30 '11 at 22:29
  • The command \renewenvironment{lyxgreyedout}[0]{\begin{comment}}{\end{comment}} in the preamble returns one error begin{lyxgreyedout} on input line 2105 ended by \end{document}. – denilw Mar 30 '11 at 22:37
  • @denilw: The comment environment doesn't stack. It reads its content verbatim and discards it. – Martin Scharrer Mar 30 '11 at 22:42
  • I'm sorry, I'm pretty new. What does "The comment environment doesn't stack" mean? If you could refer me to some short documentation to read to understand that statement that would be great. – denilw Mar 30 '11 at 22:44
  • 1
    @denilw: I meant you can't use comment environments inside other environments (or verbatim environments and similar). They do not work like normal but looking for a text match of e.g. \end{comment} which is never seen because it is inside \end{lyxgreyedout} which isn't expanded/processed while looking for it. – Martin Scharrer Mar 30 '11 at 22:53
  • Hmm, I think I get it now. – denilw Mar 30 '11 at 22:57
  • @denilw Unfortunately LyX users are a minority here, and for most of us here, LyX is a mysterious creature which hides most of the things that LaTeX does behind its interface. I don't think that means that people don't take LyX questions seriously but rather simplly that we don't have much knowledge of LyX. Also, there are many LyX things that must be done with straight LaTeX, so non-LyX solutions aren't always a bad thing. – Alan Munn Mar 30 '11 at 23:57
  • I do use ERTs if that's what you mean. If you have a solution to this problem using ERTs that would be great. – denilw Mar 31 '11 at 00:06
  • @denilw: "I find that it is possible to convince lyx to do what you want but when overriding it's default behavior I get these kinds of errors sometimes." I think that's why most people don't use LyX. I could be wrong. – TH. Mar 31 '11 at 03:50
  • It's personal preference, I certainly understand why some people don't use it. As with any piece of software it has it's flaws. Just because most people don't use Linux doesn't mean Linux isn't worth using. I have written my thesis in Lyx and I like the outlining features and commenting features. It has more to offer than Word or Kile for me. I have created presentations in Lyx and find it better than Power Point with a much better result. In short, I don't want to give up on Lyx because of some setbacks, I find it to be great software overall and I will invest time to find solutions. – denilw Mar 31 '11 at 04:10
  • Someone should just ask as a question why anyone uses Lyx and then I could answer it thoroughly once and then link to my answer every subsequent time someone asks. – denilw Mar 31 '11 at 04:12
2

The best way to approach this is in Lyx is to use branches. See here:

https://tex.stackexchange.com/a/87672

Briefly, you do to Document => Setting => Branches. There you can create new branches: just write something in the textbox above (e.g. "Longer version") and click 'add'.

Then while editing the document go to insert => branches => "Longer version". It will insert a box in which you can write some further explanations.

In the document settings you can choose which branches to include in the final version and which not to.

Clark
  • 147
  • Thanks! This is a nice community, although it's a bit unfortunate so few people here use Lyx. – Clark Aug 18 '16 at 00:04
1

You might also consider using PDF annotations with the pdfcomment package.

There's a Lyx module, which at least partly supports pdfcomment. You can use the final option to switch off the comments.

Here's a blog post, how to make it work.

Josef
  • 7,432
  • +1 This seems very promising I will look at it in detail on the weekend. – denilw Mar 31 '11 at 16:01
  • The link you provided http://blog.ibd.com/howto/getting-commentsannotations-in-lyx-to-show-up-in-pdf/ is excellent. – denilw Mar 31 '11 at 16:07