I like to work out my solutions on my own for what I need. Sometimes it really involves some struggle, but that's part of the fun, cracking the puzzle. On the other hand I think others could also profit from the results. TeX.SX is a community site, but rather geared towards a Q&A format with incentive mechanisms to keep it as fair and balanced as possible.

So, if I would like to publish code snippets of my own, I could post a question and slap on the answer I already have. This is not the best way to proceed ethically, IMHO. Should I instead post it as a community wiki? But then again, if someone wants to add his contribution, which might be really outstanding, he will be deprived of his rightful reward... Or should I use some other outlet, e.g. blog post? Maybe this is a bit of hair-spitting, but I'd like to know your thoughts on that.

  • 2
    Slightly outdated, but essentially still true: meta.tex.stackexchange.com/questions/4/…
    – Caramdir
    Dec 8, 2012 at 15:35
  • 10
    I believe the consensus is that posting "fake" questions to which you know the answer is perfectly fine (I personally think it's a really good thing), but it's a good idea to wait a bit before posting your own answer.
    – Jake
    Dec 8, 2012 at 16:08
  • Interestingly, GitHub-like punchcard with the help of pgfplots did exactly what you're describing within 30 minutes of your question
    – cmhughes
    Dec 8, 2012 at 16:43
  • 3
    @cmhughes Even mmore interestingly, he did not accept his own answer ...
    – mafp
    Dec 8, 2012 at 18:01
  • @mafp There's some time delay before you're allowed to accept your own answer.
    – Alan Munn
    Dec 8, 2012 at 19:02
  • 1
    When posting a question that you intend to answer, I would make sure that your question is completely honest. Dec 8, 2012 at 20:14
  • @AndrewStacey: What exactly do you mean by 'completely honest'?
    – Count Zero
    Dec 8, 2012 at 20:26
  • 1
    I mean that you should say that you already have an answer and will post it shortly, maybe give a hint as to your solution. Dec 8, 2012 at 21:27
  • stackexchange blog would be best place for those kind of puzzle crackings. for example the A perl script for indenting .tex by @cmhughes and many more. The latest posts are placed on right hand side of TeX.SX for few weeks like community bulletin. Dec 9, 2012 at 4:56
  • 1
    @AndrewStacey It is possible to write the answer to your own question as you post the question.
    – N.N.
    Dec 9, 2012 at 9:57
  • I do not think it is problematic at all to answer your own question. It should rather be encouraged as it helps to share knowledge which is the main goal. Also, if someone posts an answer that is better than your answer to your own answer it will hopefully be rewarded by getting votes.
    – N.N.
    Dec 9, 2012 at 10:05

2 Answers 2


Let me expand a bit on my comment. I think that there are some basic guidelines for this sort of thing (note: guidelines, not rules).

  1. This is a question-and-answer site. So make the question bit a question and the answer bit an answer. Imagine that you are a user with a problem and phrase your question accordingly. As you already know the (or "an") answer, try to ensure that the question is as helpful as possible - remember that it is the question that users will use to determine whether the answer will be useful to them or not. If you can't separate your recipe like this consider rather posting it as a blog post.

  2. Be honest. Although your question should be a genuine question, you should be honest about having an answer already. Unless you intend to answer straight away, the chance is that someone will look at your question and try to help you. Saying that you already have an answer says to them that answering your question shouldn't be a high priority (though folk do like a challenge so someone might try to answer it anyway - the point is, though, that they won't be annoyed with you when you post your answer). But keep the question in the question and the answer in the answer.

  3. Be humble. You are posting your question-and-answer to help others, but leave yourself open to the possibility that you can be helped yourself. Your solution might not turn out to be the best or there might be something that you overlooked which doesn't affect you but might affect someone else using your code.

  • 4
    +1 I especially second the "be honest" idea. Saying that you have an answer but "you're looking for ideas of others as well" is important to avoid people getting angry on you.
    – yo'
    Dec 9, 2012 at 21:51

The traditional (and still valid) way is to make the code into a package and stick it on ctan.

  • 12
    Whereupon someone will use it, find some unexpected behaviour, and ask a question about it here. Then you can post some more code as an answer and the cycle begins again. Dec 12, 2012 at 22:32
  • (+1) I do agree. But, of course, this is a lot more work. Plus, I'd want to be rather more confident of my code before I posted it on CTAN! And some things should maybe not be packages...? Posting untested (i.e. tested only by me) code on CTAN seems dangerous. At least, if I wrote the code....
    – cfr
    Jun 22, 2015 at 20:26
  • @cfr there was a time (before people worried about licences and stuff) that untested code posted as answers on comp.text.tex would find its way on to ctan all by itself... Jun 22, 2015 at 22:02
  • But it may have been written by people who knew what they were doing....
    – cfr
    Jun 22, 2015 at 22:07
  • @cfr unlikely:-) Jun 22, 2015 at 22:07

You must log in to answer this question.

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