2

Although I've been using LaTeX for a long time, I never defined "dynamic" new commands. Here is what I have in mind:

I define a new command such as \newitem with the following inputs

\newitem{category}{style}{ref}{title}

Now, I want to use category and style to sort in the content list, to use ref in the bibtex, and use title to be shown. However, I don't know how to implement this.

I want the content to be listed according to category first, then according to the style. Additionally, I don't know how to add ref to the bibtex systematically.

Let me just explain what I expect from my \newitem to do. Consider, I have the following in my TeX file:

\newitem{spin}{lecture}{Ed. Nelson, someconference}{New method to rotate spin}
\newitem{ion}{paper}{Loss et al, someaddress}{New method to manipulate ions}
\newitem{spin}{paper}{Z. Yu et al, pra.....}{Another method to rotate spin}    .....    

I expect the following PDF output:

Table of Content

  1. Spin
    Lecture
    1. New method to rotate spin
    2. ....
    ...
    Paper
    1. Another method to rotate spin
    2. ....
  2. Ion
    Lecture
    1. ....
    2. ...
    ....
    Paper
    1. New method to manipulate ions
    2. ...... ...

References

[1] Ed. Nelson, someconference
[2] Loss et al, someaddress
[3] Z. Yu et al, pra.....

P.S. Sorry for the confusing question.

fred
  • 21
  • Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or [enclose words in backticks ```](http://meta.tex.stackexchange.com/q/863), they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – Adam Liter Jan 25 '14 at 18:27
  • 2
    bibtex is a program to manage a bibliography database, how does it fit with you ref argument? I think you will need to show a complete (small) document) and describe the output you wish (I can not guess from your description) – David Carlisle Jan 25 '14 at 18:40
  • 3
    Please clarify the question. It seems to mix up lots of different topics (table of contents vs. index/sorting, \label/\ref vs. \cite/bibliography). – Heiko Oberdiek Jan 25 '14 at 22:14
  • Thanks for your responses, and sorry again for my confusing questions. My question touches different topics (contentlist, ref,..), but mostly I am concerned with creating a customized content list. – fred Feb 02 '14 at 18:13
  • For the sorting stuff, you are probably better off using an external database (like a .csv file) and sorting it with the datatool package. But it is not at all clear what the logic of the sorting scheme is. Why 'spin' before 'ion'? why 'lecture' before 'paper'? how many total categories are there? And why do you want to input them all in an unsystematic way? It would be so easy to sort the above \newitems by hand that I don't see where the advantage lies for not doing it yourself... – jon Feb 02 '14 at 23:11
  • What do you mean by "ref to the BibTeX"? Do you want a hyperlink to the entry in your bibliography? If not, I guess a number is sufficient, but where do you put that number in the list you've created? – Werner Feb 03 '14 at 05:56
  • @fred I voted for reopening the question, after your edit. But it's still unclear; what about the items you denote with 2. ...? How would you organize the input? – egreg Feb 03 '14 at 07:48
  • The motivation is to have a latex friendly and flexible research diary. I have searched online and I could not find anything practical. So I have some predefined labels such as "spin" and "ions" which categorize my research domain. And there are some type specified for each entry, for example, paper, or lecture note, etc. – fred Feb 03 '14 at 16:17
  • Now, I aim to add new item to my diary at anytime, and later I would be able to categorize them according either to the subject category (e.g, "spin" or "ion" here) and/or type (lecture, paper, etc). – fred Feb 03 '14 at 16:26
  • Have you used bibtex before? If not, I think the first thing you should do is to set up a simple .bib database for papers etc. you want to cite and then learn how to cite these and produce a list of references in a document. Once you are confident doing that, then you can work on expanding on that knowledge. Right now, there's just too much here for one question. It isn't a matter of explaining how to create a new command, it is also everything else ;). – cfr Aug 06 '15 at 01:02
  • For new commands see my answer on this. For bibliographies see this question. – cfr Aug 06 '15 at 01:05
  • 1
    If you used Biber/Biblatex and configured an appropriate .bib file, you could potentially do most of this that way. That is, put the categories etc. into the .bib file and then use the filters and selective printing commands provided by Biblatex. – cfr Aug 06 '15 at 01:07

0 Answers0