You are not logged in.

#1 2009-06-08 10:05:33

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Latex: how do you insert text from an external file?

I would like to include various quotations in a Latex document. I want to display the quotation in the text along with the author, followed by a reference citation, e.g.

Some example text here before the citation.

"Here's an example of the citation."
Xyne \cite{xyne_quotations}

This is the next section of text followed by more text.

The citations are easily done with Bibtex, e.g. in a bib file:

@BOOK{xyne_quotations,
   author = "Xyne",
   title = "Xyne's big book of quotations",
   publisher = "Arch Linux Publications",
   year = 2009
}

and the auto-generated reference section would contain something like

[1] "Xyne's big book of quotations", Xyne, 2009, Arch Linux Publications, etc

I could define a custom command to accept 3 arguments (quote, author, bibtex key) and use that in the text, but I would prefer to create a separate file which lists all of the quotations with their own keys, so that I could do something like this in the latex document instead:

Some example text here before the citation.

\insertquote{xyne_example}

This is the next section of text followed by more text.

with the quotations file following a format such as

@QUOTE{xyne_example,
   quote = "Here's an example of the citation.",
   author = "Xyne",
   citation = "xyne_quotations"
}

and get the same result as above. Effective this would be a quote database and I would only need to create an insert command in the tex file to pull in quotations.



I'm sure that this is possible in Latex. It seems like all I would need is a variation of what bibtex does in which the quote and author are inserted along with the citation. The question is how do I do it (and how difficult is it)? I just can't find instructions for doing something like this. I'm hoping someone here will have an idea so I can avoid signing up for yet more forums. Any help is appreciated.

Last edited by Xyne (2009-06-08 10:24:43)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2009-06-08 22:37:22

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: Latex: how do you insert text from an external file?

If you can keep the quotes in separate files, you can use \input or \include, and then define your \insertquote with \newcommand which can apply the correct prefixes to the argument.

Also consider abusing bibtex and storing the quotes in the author or notes field (and then the formatting can somehow be worked around)

Offline

#3 2009-06-08 23:47:57

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Latex: how do you insert text from an external file?

Thanks for the reply, vogt.

I had a look at both the commands that you mentioned but as you pointed it I would have to keep the quotes in separate files which seems to defeat the purpose (it would be easier to just include them directly in the document).

The second idea is one that I've had myself but I have no idea how to do that or how I could create a custom Bibtex clone that inserts more than just [1] in the text. If you have any examples or links to tutorials please let me know, I've never done anything beyond inserting colors and images and using custom commands so I don't even know what terms to search for to find what I need.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#4 2009-06-09 12:23:28

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Latex: how do you insert text from an external file?

A quick search turned up 'quotepas' latex package: http://theoval.cmp.uea.ac.uk/~nlct/late … anual.html
I don't know if it's enough for your purposes...

Offline

#5 2009-06-09 20:32:22

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: Latex: how do you insert text from an external file?

Thank you for the link.

I made a PKGBUILD for [url]http://aur.archlinux.org/packages.php?ID=27131 quotepas[/url].From the same author there also is a package datatool that allows a similar task. datatool is included in texlive-latexextra.

Btw, the webside includes lots of documentation/howtos for  LaTeX and its use in science.

Offline

#6 2009-06-10 05:36:01

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: Latex: how do you insert text from an external file?

@bender02 and Stefan Husmann
Thank you both. I'll look into that and see if I can get it to do what I want.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB