 All right, what's up guys? So in this video, we're gonna show you how true Unix chads do their references and bibliographies Indocuments all automatically without any of the effort now if you've seen my channel before you of course know that I've done videos on law Tech Where you can automatically do references very simply just by having a bibliography file and using something like bibber But if you saw my last video I compared to bibber with what is called refer now refer I should say is a what's called a preprocessor for graph now refer and graph They're usually part of like a base develop package on your on your any Unix based operating system So chances are you probably already have these But they are a highly minimal way of getting citations Citations and references in your document you can check out my last video where I compared them to law tech and needless to say They're much quicker and much much more efficient, but in this video I'm actually going to talk about how to use refer Okay, so anyway now the very basics what in this video? We're going to really just put in references into this document just to show you how it works now in order to First prepare your references. You're gonna want to have some kind of bibliography database now That could be a database of one resource or it could be a database of a gajillion resources I'll go ahead and pull mine up here So this is my bibliography file. I actually converted it a little bit ago So on my right here, this is my bibliography file for law tech I've been building this up for like years as I cite things I'll put them in here and I'll never have to worry about them again because a lot tech will format them automatically But the same thing is true with graph and refer Really, all I did is I converted the document on the right to the document on the left It's not actually totally converted but mostly Done now. Let's go ahead and look at the formatting of this So each of these paragraphs is a separate reference a separate source Maybe a book maybe an article maybe an article in a book or something like that And you'll notice that all of the metadata is sort of tagged here So for example the I was about to say artist the author is tagged in capital a the title is in capital t The book if it's an article in a book is tagged with capital B You'll see the editor is tagged in E Publisher and I Etc. Etc. If you want to see all this information you can just go to the refer Man page and it'll actually list out a little bit down here all the different metadata you can give it But needless to say you can pretty much Give all the stuff that you need in this file And that's really all you need to set this thing up now note that when you have multiple Authors here for example this resource has two authors you put them on separate lines That's a little different from in la tech where you usually put them all in one author thing same thing with editors or anything else But once you have this done you'll pretty much be able to format any kind of Document with refer now. I should say in addition to this notice now Remember if you if you're familiar with a lot tech usually what you do is you tag Like each reference has its own abstract name that you refer to it as like if I want to call this source here I have to refer to it as Baker 88 in my document now I have copied these over to my refer document But those are not actually necessary because refer is a little better because refer can mark It can match some keyword or tag you've given a Reference, but it can also just find particular words that are in it And if it finds a close enough match it will Return the document you're looking for I'll give an example of that in just a second Let's go ahead and get into it actually. Let's in fact, let's do an example of it right now So here I have a graph document and in the last video we talked about how to compile graph documents I just have one with the MS macro. So I have graph MS run it on this file output it to PDF and put it in this file. That's all that's saying now in order to use refer Well, let's actually run just refer first just to see how it works now first I'm gonna add in let's say. I want to cite something in this document Let's say I just want some citation right here now the proper syntax for that is going to be a come Dot and then open bracket and we're gonna in that command with dot close bracket and refer is going to read all the text between that as It's well It's really just gonna process all the text that it finds between now if I want to cite something. Let's say I want to cite Let's say I want to cite Hamlet's mill which is a book I have over there, and I think I have it in my reference file I don't have to remember the tag. I gave that file or the keyword I gave it I can really just say okay Hamlet's mill That's probably a distinct enough title that it's going to find that now Let's run refer first and see what it does. I'm gonna make it a little bigger here If I run refer now, I'm gonna do it is gonna give it the P option and I'm gonna select my Bibliography file so it knows what bibliography file to look at and then I'm gonna pick my file here And I'm just gonna run just refer and to show you what it what it does what it does is it outputs The the same document we input it except for this stuff that's between the brackets This has been replaced with that the information of that source we're looking for and it looks like we have the right one So great, that's what we want now in practice what you're gonna do with this is that you are going to pipe it into graph so I'm gonna pipe it into graph and I'm gonna say again. We're using the MS macros and Say again, I'm going to put that in the PDF and that is going to be Exampled up PDF so now I'm gonna run this and you'll see it's a little subtle because my font is small But I'll zoom in a little you'll see we now have a little footnote here And if I scroll down you'll see that the reference has now been properly formatted Everything's are you know the title is italics and stuff like that Everything is nice in the bottom of the page. So that's what we expect again We don't have to write any of that stuff out In fact, you don't even have to remember the keyword like you do you do in law tech All you have to do is just do that and your references are in there now Let's talk about customizing this because you might not necessarily want to footnotes or something else now refer Has a couple different options you can give it now you can of course I'm gonna show you a couple of the ones that I use actually. Let me pull up the command that I use in my Compiler script here. You'll see I give it a couple options here PS and E. Let me let me I should probably just go ahead and show you what that does if I give it capital s For example, what that's gonna do is change the label used here. That is if I don't want to use a footnote This will present it as the author name and the year now. This is a label now What the label means is it's actually gonna label this footnote down here as that as well now that I find a little strange But it's easy easy enough to get rid of I should also say oh, yeah one other thing as I said I give it the capital P option as well You'll notice that the exclamation point here is Right before the reference and sometimes you really want the reference to be inside of the sentence I mean in most style guides. So if you give it capital P, it is going to move it over there Another thing I don't necessarily like footnotes. I like having rolling bibliographies So one thing I can do is give it the E option and what that E basically means accumulate if you look at the references and what accumulate does is instead of Putting everything immediately down in the footnotes. It just keeps Accumulating all the references you cite and then puts them in a Basically a references section at the end of the document. Now. This is more This is basic custom Customizability, but there are other commands that you can give it to give it more. I guess fine-grained grain details So let's say I want to well most of these options I should go ahead and say at least on GNU groff not necessarily the original trough, but you can give them Additional options up here. So if you put in R1 and In that sequence with R2 in between that you can put extra options You can replicate some of the behavior that we had with these options here But one thing I think I noted just a second ago is I don't really like the labels Being down here in the references. So one thing you can give it is no label in Reference, I think that's it Let me check did that work. Oh, no, that's it's not what I meant to wait It's not what I meant it to do. Sorry. I just lost myself for a second. Yeah I forgot sometimes when you give it extra options in here, it'll overwrite the stuff you given on the command line So if I want this reference to still be in its own references section, you have to manually Specify accumulate in the document. So I'm gonna do that as well. And that's only if you have one of these Code areas where you say Additional settings. Now the other thing is I put these up here at the top of the document That's sort of arbitrary as long as they're before the brackets here It's not gonna matter where they're gonna be now The other thing is you can of course specify different rules for different Areas of brackets like let's say you want You know one chapter or one section to for all the stuff to be in the footnotes You could have another R1 R2 code area here where you specify not to accumulate and specify, you know, tell them just to continually Go to the the footnote section or whatever Additionally now just to be clear there is a lot of formatting stuff that's done automatically So if I throw in more references here, although we have to pretty much use I think you have to use only one reference per bracket. If we do put in let's say we put in You know Chomsky let's put in Chomsky whatever and see what it does actually because I obviously have multiple Chomsky things So it will put in. Oh, actually this illustrates two things So it'll put in the reference but notice also I should show you I meant to show you without the accumulate tag It will also automatically format the format here so that instead of having them in separate parentheses They're all Unified under the same parentheses and separated by a semicolon You can change that format if you want if you want them to be separated by comma or put in brackets Just check the manual for that now I will in addition to that you'll see that I got this little warning here and it says multiple matches for Chomsky and That is because in my reference file There are a whole bunch of stuff that have the sequence Chomsky in it So if I want one particular one in order to be safe I should specify more of the title or more of other bibliographical data So let's say I want Chomsky's thing on three factors and language whatever it is So I'll just recompile that and you'll see that it's now Chomsky 2005 and that is three factors and language design. That's the one I want Okay, so it's pretty Manipulatable and the error it gives you here is not fatal that can be good and that can be bad depending on what you're looking for But just be aware of that as well Now I want to give you one more little use case that I think is pretty useful again It's in the manual But I just want to show you that it's there and that is the list function now again You can accumulate references and by default they're all going to go at the very bottom in a separate reference section But if we want let's say we want We want different chapters or different headings and at the end of those We want all the references from those sections to be there with their own chapter So you don't have to go all the way to the end of the document or something like that That's something that people want all the time. So let's well first off. Let's turn on accumulate by default and what we're gonna do here is First well, let's go ahead and recompile this So now we have our references all here at the very end here But what let's say we add another section? Okay, so I'm gonna say new header and new section New section and here's another paragraph So and of course if we recompile this the references are still going to be at the very end now what we can do is we can Start another little bracketed off area and we can just type in list between two dollar signs And if we do that and recompile it you'll see that what happens is all of these references that were Accumulated up until that point print out whenever you type in list and if we add in some other let's add in another reference let's say Thinking fast and slow which I have on my desk here, which I think I have in my Yeah, I do have it on my bibliography file. So here you'll see that this Reference is going it since you know it it is accumulated. It's just gonna end up at the very end Unless we type in a print command, but these references or not a print command a list command These references since we have this list function here. They print out where we put that function So that is how you can get things like and of course you can you can simplify this by doing macros for refer or something Else like that, but this is generally how you can get that kind of functionality now I have refer is a very very big place Check the documentation for refer check other resources on refer There are lots of ways to change, you know, what kind of what the labels look like Where they appear what they do all of this detail I'm not going to give you it all here, but I hope this has given you a good enough view of it and this is going to be Additionally refer is I guess a preview to other preprocessors in graph and notice what we're doing If you remember what happened when we originally ran the graph command all it does is it? Modifies the text stream of the document replacing particular sequences Which with new data that a graph can read and this is what other preprocessors are going to do as well For example, there is pick for making diagrams. There is EQ in for making equations similar to law tech's math mode I'm going to do a video on that I might do a video on other ones as well But all of them work in the same way that is they just modify certain select portions of the stream And send them off to graph for graph to do whatever it needs to do and that's one of the reasons this is such an efficient program It's not it's not like law tech where it's creating a gajillion build files and doing all this really hardcore stuff It's just modifying a text stream that eventually is going to end up as a post script or a PDF file So anyway, so that's about it. I hope you learned something and I'll see you guys next time