GeneralDatabase, List, References

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
srosendal
Posts: 4
Joined: Thu Nov 16, 2017 1:34 pm

Database, List, References

Post by srosendal »

Hi

I would like to create a list with 50 items or so. Each item needs 3 names, for example with

Reference: Number: Item: Description
tag01: 091102S61S01: Push Button: Start sequence
tag02: 091102S61S02: Push Button: Stop sequence
tag03: 091102S61S03: Button Switch: Mode Selector

I want to make references to these, say my text will be:

When operator push /tag01 the machine starts
When operator push /tag02 the machine stops

Actual text should be
When operator push 091102S61S01: Push Button: Start sequence the machine starts
When operator push 091102S61S02: Push Button: Stop sequence the machine stops

I tried with BibTex, but it was not good, too difficult to get the actual text right

Anyone wanna try ? THX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Database, List, References

Post by Stefan Kottwitz »

Welcome to the forum!

Perhaps show what you tried. Besides BibTeX, you could use biblatex.

Stefan
LaTeX.org admin
srosendal
Posts: 4
Joined: Thu Nov 16, 2017 1:34 pm

Database, List, References

Post by srosendal »

Thank you

What I get is:

When operator push 'start sequence' (1s01) the machine starts
When operator push 'stop sequence' (1s02) the machine stops


I want a form like year:title:author

---------------------------------------------------------------------
MY MAIN

\documentclass{article}
\usepackage{natbib}

\title{test}
\author{test}
\date{\today}

\begin{document}
\maketitle
When operator push \citet{tag01} the machine starts\\
When operator push \citet{tag02} the machine stops

\newpage
\bibliographystyle{apalike}
\bibliography{bibliography.bib}

\end{document}

---------------------------------------------------------------------
MY BIBLIOTGAPHY.bib

@book{tag01,
title={push button},
author={'start sequence'},
volume={},
year={091102s61s01},
publisher={}
}
@book{tag02,
title={push button},
author={'stop sequence'},
volume={},
year={091102s61s02},
publisher={}
}
srosendal
Posts: 4
Joined: Thu Nov 16, 2017 1:34 pm

Database, List, References

Post by srosendal »

so, guess it is not that simple afterall :)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Database, List, References

Post by Stefan Kottwitz »

At least I did not use such a method. I can help in troubleshooting stuff, no time for engineering new things.

If you find out something, let us please know. I'm interested.

Stefan
LaTeX.org admin
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Database, List, References

Post by nlct »

You could try using the glossaries-extra package. For example:

Code: Select all

\documentclass{article}

\usepackage{longtable}
\usepackage[nostyles]{glossaries-extra}

\newcommand*{\newoperation}[4]{%
  \newglossaryentry{#1}{name={#2},symbol={#3},description={#4}}%
}
\newcommand*{\operationref}[1]{%
  \glsdisp{#1}{\textbf{\glsentryname{#1}: \glsentrysymbol{#1}: `\glsentrydesc{#1}'}}%
}

\newoperation{tag01}{091102S61S01}{Push Button}{Start sequence}
\newoperation{tag02}{091102S61S02}{Push Button}{Stop sequence}
\newoperation{tag03}{091102S61S03}{Button Switch}{Mode Selector}

\newglossarystyle{operation}{%
  \renewenvironment{theglossary}%
   {\begin{longtable}{lll}}%
   {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Number & \bfseries Item & \bfseries Description\tabularnewline
    \endhead
  }%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrysymbol{##1} & \glossentrydesc{##1}\tabularnewline
  }%
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
  \renewcommand*{\glsgroupskip}{}%
}

\begin{document}

When operator push \operationref{tag01} the machine starts
When operator push \operationref{tag02} the machine stops

\printunsrtglossary[title={List of Operations},style=operation]
\end{document}
This will list the items in the order that they were defined.

Since you already have a .bib file, here's another approach using glossaries-extra with bib2gls. If file "testdata.bib" contains:

Code: Select all

@entry{tag01,
 operationnumber={091102S61S01},
 operationitem={Push Button},
 description={Start sequence}
}

@entry{tag02,
 operationnumber={091102S61S02},
 operationitem={Push Button},
 description={Stop sequence}
}

@entry{tag03,
 operationnumber={091102S61S03},
 operationitem={Button Switch},
 description={Mode Selector}
}
Then the document can be changed to:

Code: Select all

\documentclass{article}

\usepackage{longtable}% needed for custom style
\usepackage[nostyles,% using a custom style
 record% using bib2gls
]{glossaries-extra}

\GlsXtrLoadResources[
  src={test-data},% entries defined in test-data.bib
  field-aliases={% convert custom field names to keys recognised by glossaries-extra.sty
    operationnumber=name,
    operationitem=symbol
  },
  sort=letter-case,% case-sensitive character code sort
  sort-field=name% sort by 'name' field (which has been obtained from 'operationnumber')
]

\newcommand*{\operationref}[1]{%
  \glsdisp{#1}{\textbf{\glsentryname{#1}: \glsentrysymbol{#1}: \glsentrydesc{#1}}}%
}

\newglossarystyle{operation}{%
  \renewenvironment{theglossary}%
   {\begin{longtable}{lll}}%
   {\end{longtable}}%
  \renewcommand*{\glossaryheader}{%
    \bfseries Number & \bfseries Item & \bfseries Description\tabularnewline
    \endhead
  }%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrysymbol{##1} & \glossentrydesc{##1}\tabularnewline
  }%
  \renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
  \renewcommand*{\glsgroupskip}{}%
}

\begin{document}

When operator push \operationref{tag01} the machine starts
When operator push \operationref{tag02} the machine stops

\printunsrtglossary[title={List of Operations},style=operation]
\end{document}
This only includes the tag01 and tag02 entries in the list, as the default action is to only select the entries that have been referenced in the document. If you want to include all entries defined in the .bib file, then just add selection=all to the resource options:

Code: Select all

\GlsXtrLoadResources[
  src={test-data},% entries defined in test-data.bib
  field-aliases={% convert custom field names to keys recognised by glossaries-extra.sty
    operationnumber=name,
    operationitem=symbol
  },
  sort=letter-case,% case-sensitive character code sort
  sort-field=name,% sort by 'name' field (which has been obtained from 'operationnumber')
  selection=all
]
The document build process is much the same as with BibTeX but replace bibtex with bib2gls.

Regards
Nicola Talbot
srosendal
Posts: 4
Joined: Thu Nov 16, 2017 1:34 pm

Database, List, References

Post by srosendal »

Thank you very much for your answer, it did help :)
Post Reply