3
$\begingroup$

I give a CellTag to my Input Cell, but the output cell would also inherit the CellTag.

Is it possible to control not inherit the CellTag?

Sometimes I need the output cell with the CellTag, but sometimes I don't need...


Application

I found another method is use another tags to do the same thing.

I want to select some cells with some tags, cells with "Ignore" tag will be omitted, only Input Style Cells with"Ignore1" tag will be omitted, Output Style Cells with "Ignore1" tag will be kept.

for example, I select the cells without "Ignore" and "Ignore1" tags.

Select[NotebookRead@Cells[EvaluationNotebook[]], 
FreeQ[#, CellTags -> "Ignore"]&&FreeQ[#, CellTags -> "Ignore1"] &]

but this omit the output cells with "Ignore1", how to include these output cells?

This is my sub question, if the original question is unsolvable.


so the condition could be.

condition=FreeQ[#, CellTags -> "Ignore"] && (#[[2]] === "Output" && 
MemberQ[#, CellTags -> "Ignore1"]) &

One method

We've add a CellTags->"Ignore" in the Input cell, just add a new CellTag, the the Output cell by CellPrint will tagged by new tag Hello !

CellPrint@Cell["Test",CellTags->"Hello"]

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Main question

I don't think this is possible. You can however delete such CellTags programmatically, using this

SetOptions[#, CellTags -> {}] & /@ 
 Cells[CellTags -> "tag", CellStyle -> "Output"]

Sub question

How about something like this

Complement[Cells[], Cells[CellTags -> "Ignore"], 
 Cells[CellTags -> "Ignore1", CellStyle -> "Input"]]
$\endgroup$
6
  • $\begingroup$ yes, the problem is some "Output" style cells need "tag", some doesn't. $\endgroup$ Dec 20, 2013 at 7:11
  • $\begingroup$ @HyperGroups ah that is more specific and harder than I thought. $\endgroup$ Dec 20, 2013 at 10:21
  • $\begingroup$ I found another method to deal with this situation is Just add another tag1 to the Input Cell. $\endgroup$ Dec 20, 2013 at 10:24
  • $\begingroup$ for example, I select the cells without "Ignore" and "Ignore1" tags. Select[NotebookRead@Cells[EvaluationNotebook[]], FreeQ[#, CellTags -> "Ignore"]&&FreeQ[#, CellTags -> "Ignore1"] &], but this omit the output cells with "Ignore1", how to include these output cells. $\endgroup$ Dec 20, 2013 at 10:28
  • $\begingroup$ I've modified my question include a real application. I think you can develop your answer to make my question and your answer more applicable. $\endgroup$ Dec 20, 2013 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.