English 中文(简体)
Using LaTeX, how can I have a list of references at the end of each section? [closed]
原标题:
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it s on-topic for Stack Overflow.

Closed 10 years ago.

I want to generate the bibliography for each section, and have it at the end of the section. When I do this at the moment it generates the full bibliography and places it after each section.

Is there a way that this can be done?

The advice here says

"The chapterbib package provides an option sectionbib that puts the bibliography in a section* instead of chapter*, something that makes sense if there is a bibliography in each chapter. This option will not work when natbib is also loaded; instead, add the option to natbib. "

I don t understand what this means, and I ve tried experimenting with what I thought the options are. Specifically, what does "add the option to natbib" mean?

My subsequent question (which evolved after my first one was solved) is to not have pagebreaks between the references, and the next section.

Thank you for your help.

最佳回答

If you are using Biblatex, as for citing article titles, you can use it to produce bibliographies at the end of sections or chapters, or even have a combined bibliography where they are separated by chapter/section. As a package, it is intended to replace "babelbib, bibtopic, bibunits, chapterbib, cite, inlinebib, mlbib, multibib, splitbib."

You can put a bibliography after each section, in one of three ways. First, wrap the text of your section in a egin{refsection}/end{refsection} pair, as such

section{SomeSectionName}
egin{refsection}
% your text goes here
printbibliography
end{refsection}
section{NextSection}

Second, after each section statement you put a ewrefsection statement which ends the previous section and begins the new one. And, you precede the next section with a printbibliography statement, again. Finally, there is a refsection package option that takes either none, part, chapter, section, or subsection as an argument. To group your bibliographic entries per section in a global bibliography you use refsegment instead, using ibbysegment to print all the segments in order. (ibbysection can be used in the same manner for ref-sections, too.)

I don t know how much you ll have to split up your text, as per @Norman s answer, but with a little experimentation you can figure it out.

问题回答

In addition to

usepackage[sectionbib]{natbib}
usepackage{chapterbib}

You will have to put each section in a separate .tex file which you then include. You will have to run bibtex on each .tex file separately.

N.B. Using input rather than include avoids unwanted page breaks, but it will not create the .aux file that BibTeX needs to do its work. I looked at the definition of include, and I don t see how to disable the page-breaking function except by disabling clearpage entirely. You could try

letoriginalclearpage=clearpage
defclearpage{
elax}

right after your egin{document}, but you may have to put some originalclearpage in by hand.

@celenius - if you really want to get rid of that pagebreak, here s a very dirty trick to do it...

makeatletter
letO@@input@@input@
def@noclearpage{@ifnextcharclearpage@gobble
elax}
def@input@#1{O@@input@{#1}@noclearpage}
letO@@include@include
def@include{expandafter@noclearpageO@@include}
letO@includeinclude
definclude{expandafter@noclearpageO@include}
makeatother

Basically we perform surgery on the include macro to get rid of all the clearpage instances, but the cleanest way to do this, as you can see, is still really dirty. This is horribly brittle and will likely only work for the article class, so if you re using a different documentclass, you re out of luck. I basically derived this by enabling racingcommands=1 and racingmacros=1 and grepping the .log file for clearpage so that I could hack whatever gets called before it to insert a @noclearpage.

I don t recommend this solution - it would be much better to look into how chapterbib works and fix it the right way, without depending on include and the separate .aux files it generates... but I m positive that would be a pretty difficult task. I guess another workaround would be to write a command to emulate include s breaking up of .aux files, without actually doing the includes...


EDIT: okay, here s a quickie
makeatletter

ewenvironment{auxfile}[1]{
elax
  ifnum@auxout=@partaux
    @latex@error{auxfile environments cannot be nested or stringinclude d}
    @eha
  else@changeaux{#1}fi
}{immediatecloseout@partauxlet@auxout@mainaux}
def@changeaux#1{%
  immediatewrite@mainaux{string@input{#1.aux}}%
  let@auxout@partaux
  immediateopenout@partaux#1.aux%
  immediatewrite@partaux{
elax}}
makeatother

Then you can just insert egin{auxfile}{foo}...end{auxfile} and it will use foo.aux instead of the normal .aux file. This is fully compatible with chapterbib. I don t think CTAN has anything like this, so maybe I ll submit it as a mini-package.

I haven t tried it but as I read that it suggests:

usepackage[sectionbib]{natbib} % Note the option in the optional argument
usepackage{chapterbib}

though I m only guessing at the correct order of those lines.





相关问题
Effective Version Control for Slides

I have to maintain a huge set of training material in forms of slides. At a first glance, I ve noticed there s no support for version control in OpenOffice OOImpress (but I might be wrong on this). ...

Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...

Using vim s `gqap sometimes indents unusually

For the life of me, I cannot figure out the cause of this: when writing in LaTeX documents, I like to keep my line width to maximum of 80 characters. As such, I will execute the vim command gqap and ...

aligning math equations in Latex

I am trying to align the following equations around the equal sign. What can I do? Thanks! I am using the AMSMath package $$mddot{x}_{1}-K(x_{2}+x_{12})+C(dot{x}_{12}+dot{x}_{2})+2Cdot{x}_{1} ...

LaTeX output does not update

I have just begun using LaTeX. I am working in Windows and am using TeXnicCenter as my editor. When I build and output, having the following code: documentclass{article} egin{document} This is a ...

How to put line break in a math

I d like to express the following sentence (source_location is also italic, it s not correctly rendered): Each entry has a list of tuple: < source_location, R/W, trip_counter, occurrence, killed ...

热门标签