The latex hyperref package makes a really nice, linked table of contents, named according to section name. However, the top level category is by default, the file name. It seems I should be able to change this to the actual title, but I'm not finding any information on how.
Are you sure this is not a 'feature' of your PDF reader? It might try to use the PDFs title (unset by default), which you can set like this:
\hypersetup{
pdftitle = {The title},
pdfauthor = {You}
}
You might also want to check out the TeX StackExchange.
Related
I'm having an issue with the natbib package. When the bib entry is missing an author I want to display the editor instead. However the second citation just takes the first three letters of the bib-key instead of the author.
Sample tex:
\documentclass{article}
\usepackage[authoryear,round]{natbib}
\bibliographystyle{abbrvnat}
\begin{document}
I need this \citet[S.~2]{Test1} to look like Surname (2022, S. 2).
and this \citep{Test1} like (Surname, 2022)
But also this \citet[S.~2]{Test2} to look like Editor (2022, S. 2).
and this \citep{Test2} like (Editor, 2022)
but it just prints (Tes, 2022)
\bibliography{refs}
\end{document}
The bib file could look like this:
#misc{Test1,
author={Surname, Name}
title = {Sometitle},
year = {2022}
}
#misc{Test2,
title = {Someothertitle},
editor={{Editor, Name}}
year = {2022}
}
Can anyone help with this? I'd also switch to another package than natbib, since I'm still early on the project. But at a first glance it seemed to meet my needs quite well.
Also I don't really know what I'm doing, it's been a while since I've been working with Latex. So sorry for that in advance!
Although the user posting the initial question here was able to switch to biblatex (which is good), not everyone has that freedom for some publishing venues. If this applies to you (that you have to stay with natbib and plainnat, you may be interested in a TeX Stack Exchange post that provides a description of how you can customize your BST file to modify your sorting, including configuring misc to sort by author then editor.
EDIT: A down-check for this answer being unhelpful inspired me to be more specific than my original answer above so the additional details specific to this case are below.
Since your provided code has natbib using abbrvnat (not plainnat as in the linked example that I initially provided), you can find abbrvnat.bst in your TeX repository and place a local copy with a different name (like abbrvnat-copy.bst) into your working directory. There are two steps in modifying your local copy of abbrvnat-copy.bst: First, update the calc.short.authors function to also look for an editor in the misc type. Second, have your TeX file use your newly customized BST file.
Note: I am using the 2007 version of abbrvnat.bst, which is the latest as of this posting in 2022.
In your local copy of abbrvnat-copy.bst, search for the calc.short.authors function. We'll need to add two lines of code to it:
type$ "misc" =
or
I show the new version here:
FUNCTION {calc.short.authors}
{ type$ "book" =
type$ "inbook" =
or
type$ "misc" =
or
'author.editor.key.label
{ type$ "proceedings" =
'editor.key.organization.label
{ type$ "manual" =
'author.key.organization.label
'author.key.label
if$
}
if$
}
if$
'short.list :=
}
In your TeX file, you'll need to change this line to account for your newly customized file: \bibliographystyle{abbrvnat-copy}. Other than this one line in your main .tex file and adding a couple missing commas in your .bib file, I did not change any code in your MWE.
Here's the output:
Other aspects that you may want to address (that you didn't ask about) include getting the editor(s) to appear in the bibliography (references list) for misc entries and sorting by editor for misc entries. The example that I provided here and the example provided in the other post that I previously linked should both be helpful in customizing your BST file to achieve your desired bibliography style.
I'm producing a set of documents in LaTeX, and I would like to provide a single, global bibliography page for the whole set. This is because each document is page-limited: I don't want to take up space with references at the bottom of each one.
This means in each case, I would like to cite in the text, but not produce a reference at the end. I am using bibtex/natbib to handle the referencing.
Simplest example:
\documentclass[]{article}
\bibliographystyle{/usr/share/texmf/bibtex/bst/natbib/plainnat.bst}
\usepackage{natbib}
\begin{document}
In \citet*{MEF2010} I described the method.
\bibliography{bibliography.bib}
\end{document}
How can I do this? Essentially I just want it to cite correctly:
In Bloggs, Blagg and Blog (2010) I described the method.
But not add a references section at the end. Any ideas?
Thanks,
David
Instead of using \bibliography{bibliography.bib} you can try \nobibliography{bibliography.bib}.
You still need to enter the path so it can make the cross-references.
It happens due to missing packages. If you want to resolve the problem then enable the automatic installation packet. After that,First, you run the BibTeX file and generate the Pdf file (instead of pdfLatex file) and then pdfLatex to Pdf
In my document I have to specify the references I'm using. I used this code in the preamble:
\bibliographystyle{abbrv}
\bibliography{main}
Where main is the .bib file from the same folder, and contains, for example:
#string{jgr = "J.~Geophys.~Res."}
#MISC{primes,
author = "Charles Louis Xavier Joseph de la Vall{\'e}e Poussin",
note = "A strong form of the prime number theorem, 19th century",
year = 1879
}
#INBOOK{chicago,
title = "The Chicago Manual of Style",
publisher = "University of Chicago Press",
edition = "Thirteenth",
year = 1982,
pages = "400--401",
key = "Chicago"
}
But at the References section nothing is displayed, when generating the .pdf. I have rebuild the .bib and the .tex file, without any changes.
And how can I change that default text, from References to Bibliografie or something else?
I think that you need to put \nocite{*} somewhere within your document -- putting it inside the preamble should cause LaTeX to throw a "cannot be used in preamble" error. If they're still not appearing within your document, is LaTeX giving you any errors and, if so, can you tell us what they are?
To change the default text from "References" to whatever you would like, use the following command:
\renewcommand{\bibsection}{\section*{insert_title_here}}
Note that the asterisk after \section means that it won't be associated with a number. If you want it to be associated with a number, just remove the asterisk.
You have to actually \cite references for them to be included in the bibliography. If instead you want everything in the bib file in the bibliography put \nocite{*} somewhere in the preamble. Read here what this actually does.
You have to either \cite or \nocite a reference for it to appear in your References section. I'm not sure how to change the name of the bibliography. I would start by looking at the LaTeX WikiBook. It looks like there is a tool make makebst that produces a custom bibliography style - take a look at the custom-bib package and this document for more details.
Why is this item not shown properly in my bibliography?
#misc{ann,
abstract = {ANN is an implbmentation of nearest neighbor search.},
author = {David M. Mount and Sunil Arya},
howpublished = {\url{http://www.cs.umd.edu/~mount/ANN/}},
keywords = {knn},
posted-at = {2010-04-08 00:05:04},
priority = {2},
title = {ANN.},
url = "http://www.cs.umd.edu/~mount/ANN/",
year = {2008}
}
#misc{Nilsson96introductionto,
author = {Nilsson, Nils J.},
citeulike-article-id = {6995464},
howpublished = {\url{http://robotics.stanford.edu/people/nilsson/mlbook.html}},
keywords = {*file-import-10-04-11},
posted-at = {2010-04-11 06:52:28},
priority = {2},
title = {Introduction to Machine Learning: An Early Draft of a Proposed Textbook.},
year = {1996}
}
EDIT:
I am using
\usepackage{hyperref}
not
\usepackage{url}
. It produces error when using url package together with it. So can the two not work together?
I would like to use hyper links inside pdf file, so I want to use hyperref package instead of url package. I googled a bit, and try
\usepackage[hyperindex,breaklinks]{hyperref}
but there is still no line break just as before. How can I do it?
EDIT:
When using url and hyperref together,
if it is just
\usepackage{hyperref}
\usepackage{url}
the compilation by latex is fine, but the link is still hyperlink and has still no linebreak. If I do not use hyperref package, the link has linebreak, but I lose hyper links. Since \url can be used in both hyperref and url packages, how can I specify which package's \url is being used?
If it is
\usepackage{hyperref}
\usepackage[hyphens]{url}
the compilation by latex command will report clash with url:
! LaTex Error: Option clash for package url.
So I wonder how I should do?
You should use them in this order:
\usepackage[hyphens]{url}
\usepackage{hyperref}
You get this error when you use them the other way around.
! LaTex Error: Option clash for package url.
since the hyperref package loads the url package somewhere internally without that hypens option, and then you want to load it with the option, so it clashes.
Turning the order around does what you want and does not give this error (since the package is already loaded hyperref won't load it again with different options)
edit: this was with pdftex, I did not test with other tools.
edit2:
or as mentioned by PatrickT in a comment: \PassOptionsToPackage{hyphens}{url} if you're using a class that already loads the package, e.g. beamer.
I just ran across almost the same problem and found it solved by putting
\PassOptionsToPackage{hyphens}{url}
before the
\usepackage[...]{hyperref}
If you mean the too-wide spacing, that's because the URLs seems to not allow line-breaks. Why this happens is another question, and the answer depends on your preamble (the packages you use etc.). In principle, if properly used, the url package should allow line breaks.
EDIT
This problem (and its solution) is described here (sending you to a Google cache since the site is offline at the moment). Bottom line: either use the breakurl package, or PDFLaTeX, or both.
Weird, I load the url package (with no option) and hyphenation is done at the slashes / if needed.
Anyway, simple workaround:
howpublished = {\url{http://www.cs.umd.edu/}\url{~mount/ANN/}},
Manual job, but it splits up the URL yes or yes.
for me only this worked:
\usepackage[hyphens]{url}
\usepackage{hyperref}
...
\usepackage{biblatex}
\setcounter{biburlnumpenalty}{100}
\setcounter{biburlucpenalty}{100}
\setcounter{biburllcpenalty}{100}
Taken from: https://tex.stackexchange.com/questions/22854/url-line-breaks-with-biblatex
Normally URLs are hyphenated, but in your bibliography they seem not to be. When the URLs don't fit on one line, they are moved to the next line, and the text before them is stretched to fill out the preceding lines. Since there is only one place to break the line, it's not very likely that the preceding text will fit nicely into a whole number of lines, and so you get all the extra space.
EDIT: When you changed your bib entry, you happened to change it in such a way that the text did fit nicely. This is just a coincidence, you didn't fix your problem.
I suspect that putting
\usepackage{url}
in your preamble will solve it.
If url package doesn't help, try:
\usepackage{xurl}
\usepackage{hyperref}
Package xurl is an expanded version of url, which allows line breaking at every point in the url. Call xurl before hyperref.
Source: Does the hyperref breaklinks option have any effect?
I add this package:
\usepackage[hyphens]{url}
and in the bibtex I used:
howpublished = {**\url{**http://www.......**}**}
and it works out.
This simple solution worked for me:
\usepackage{hyperref}
\usepackage{breakurl}
The URLs are now perfect.
At the preamble, just put \usepackage{breaker} somewhere after \usepackage{hyper ref}. The \burl command is defined and, by default, the package also turns the \url command into a synonym of \burl.
So far the hyperref package in LaTeX has automatically linked all the items in my report correctly. But there is one that did not get linked properly, possibly because I manually added it to the table of contents like this:
\addcontentsline{toc}{chapter}{Bibliography}
How do I fix this?
You have to use the \phantomsection macro just before or after the \addtocontentsline. This instructs hyperref to add an anchor at that point. Also, take into account that you have to run LaTeX several times to make this anchor to be in the exact place.
If you're using a standard LaTeX document class, such as report, you can use the tocbibind package, and then you won't need the \addcontentsline command and the hyperlinks should work correctly. From the documentation:
The tocbibind package enables the titles of the Table of Contents, the List of Figure, the List of Tables, the Bibliography and the Index all to be added to the Table of Contents.
I'd also suggest looking at the memoir class, which also solves this problem. It's intended to be a replacement for the standard report and book classes, and provides lots of options and commands for customisation.