My LaTeX code is:


Required Output is:

If arttype value is 5:

`5thArticle Title-tnins` is need to store in \newcommand `\arttext`.
`5thArticle Short Title-tnins` is need to store in newcommand `\artshortname`.
`5thArticle Sub-Title-tnins` is need to store in newcommand `\artabbrtext`.
`5thArticle Color X-tnins` is need to store in newcommand `\artcolor`.
`5thArticle Misc. Value-tnins` is need to store in newcommand `\artmisc`.

If arttype value is 8.

`8thArticle Title-toins` is need to store in \newcommand `\arttext`.
`8thArticle Short Title-toins` is need to store in newcommand `\artshortname`.
`8thArticle Sub-Title-toins` is need to store in newcommand `\artabbrtext`.
`8thArticle Color X-toins` is need to store in newcommand `\artcolor`.
`8thArticle Misc. Value-toins` is need to store in newcommand `\artmisc`.

arttype value is n number of times. I will print the each \art* values in each paragraph separately. How do control in LaTeX class file?

  • On the surface, it appears you would like the output "5th" as a string. On the other hand, perhaps you mean to signify elements of an array, in which, for example, "5thArticle Title" is some arbitrary string associated with the 5th element of the array. Perhaps a clarification would help. And if the latter, how do you propose to make these array values available to the document? – Steven B. Segletes Aug 28 '13 at 12:18
  • @Steven: I have updated the questions and 5th element is not a fixed value. In the latter i will print each array values in separate places. – Balaji Aug 28 '13 at 12:24

arrayjobx can help with such things. Perhaps this is what you're after:

enter image description here

\usepackage{arrayjobx}% http://ctan.org/pkg/arrayjobx
\newarray\arttext@aux\readarray{arttext@aux}{A1 & A2 & A3 & A4 & A5 & A6}
\newarray\artshortname@aux\readarray{artshortname@aux}{B1 & B2 & B3 & B4 & B5 & B6}
\newarray\artabbrtext@aux\readarray{artabbrtext@aux}{C1 & C2 & C3 & C4 & C5 & C6}
\newarray\artcolor@aux\readarray{artcolor@aux}{D1 & D2 & D3 & D4 & D5 & D6}
\newarray\artmisc@aux\readarray{artmisc@aux}{E1 & E2 & E3 & E4 & E5 & E6}
\newcommand{\arttype}[1]{% \arttype{<num>}
\arttype{5}\arttext\ \artmisc

\arttype{2}\arttext\ \artmisc
| improve this answer | |
  • This is easy work, but i have to store the value in variable and print to any other place (like \artcolor value should print each cross-link). No need to create any newcommand. How do achieve this? – Balaji Aug 29 '13 at 6:25
  • @Balaji: I have no idea what you mean here, sorry. – Werner Aug 29 '13 at 6:38
  • If I give \arttype{2} in LaTeX, the value of \artmisc{E2} only is like to display before \thebibliography. Not like to create any additional \newcommand or \def. – Balaji Aug 29 '13 at 6:45
  • @Balaji: Could you include these details as part of your question, making it clear in the form of a minimal working example (MWE)? I still don't understand why with \arttype{2} you only mention \artmisc{E2} when your original post lists a host of possible outputs. Also, should I interpret that \arttype{2} should pass E2 as parameter to \artmisc and friends? – Werner Aug 29 '13 at 7:30
  • I have updated the questions. I have need to print each \arttext, \artcolor separately in each paragraph. – Balaji Aug 29 '13 at 7:55

Here is an answer if your data is in an external file (data.tex). If your data file is as follows:

article 1 title
article 1 short title
article 1 sub-title
article 1 color
article 1 misc value

article 2 title
article 2 short title
article 2 sub-title
article 2 color
article 2 misc value

article 3 title
article 3 short title
article 3 sub-title
article 3 color
article 3 misc value

article 4 title
article 4 short title
article 4 sub-title
article 4 color
article 4 misc value

Memoirs of a LaTeXer
Mem. LaTeXer
Nerds Gone Wild

then this MWE:

\newcommand\arttext[1]     {\artloop{#1}{1}}
\newcommand\artabbrtext[1] {\artloop{#1}{3}}
\newcommand\artcolor[1]    {\artloop{#1}{4}}
\newcommand\artmisc[1]     {\artloop{#1}{5}}
\parindent 0in
\underline{Data for record 5:}\\

will read through the records to produce the following:

enter image description here

| improve this answer | |
  • 2
    I think I have Nerds Gone Wild on one of my external drives :P – percusse Aug 29 '13 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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