Styling of biblography - change underline to italic (Latex) - latex

I am struggeling with latex biblography styling.
Using the predefined
\bibliographystyle{plain}
style i get a nice result:
When adding the following package:
\usepackage {ulem}
I get this result in the biblography:
How can i remove the underline of the journal and get it italic?
I tried:
\renewcommand{\uline}[1]{\textit{#1}}
and also following, to undefine \uline
\renewcommand\uline[1]{}
But both create a lot of "Missing } inserted.\end{thebibliography}" in the bbl file. Is there a way to revert the \usepackage command or get back the old style?

One of the features of the ulem package is to redefine \emph so that it uses \uline, so (as is presumably already clear to you) that's why you're getting underline in the bibliography, where text was emphasised before.
The documentation for the ulem package notes that adding the [normalem] option when loading the ulem package means that \uline is defined but \emph isn't redefined. I don't know if that would be an acceptable solution for you – ie, do you in fact want \emph to be underlined throughout the rest of the document?
Alternatively, if you only want \emph to go back to its original definition for the bibliography, you could try (ulem docs again) giving the command \normalem before loading the bibliography. However, the way that the bibliography is loaded can sometimes make it unexpectedly difficult to fiddle with its formatting (as you've discovered, when trying to redefine \uline).
If these thoughts don't resolve things, try posting a ‘minimal working example’. You may also be better off looking at, or possibly posting to, the TeX stackexchange.

If anyone faced the issue of getting \hbuf errors in the Bibliography.
The Solution by NormanGrey helps in this case also:
The documentation for the ulem package notes that adding the [normalem] option when loading the ulem package...
Thus, just by making a small change in the settings.tex fixed this error:
\usepackage[normalem]{ulem}
It not only removed the underline, it fixed the overflow I had, as you can see here:
to
Thank you a lot.

Related

no automatically word wrap with bibliography

I have a problem with my biblatex. My booktitles don't automaticly break lines in my bibliography. Has someone got a hint how to solve this? Is it possible to get an automatic break or do I have to set them manually? And if I so, how do I do that?
Here my biblatex code snippets:
\usepackage[backend=biber,style=authoryear,sorting=nyt,citestyle=authoryear]{biblatex}
\printbibliography[type=book,title={Books}]
See this example at IEEE: after Metrics is a linebreak is missing.
EDIT: I found the solution here
I was curious about the \emph{} style (mine was always underlining). I put a single \normalem in front of the \printbibliography command and it works fine :)
\normalem
\printbibliography[type=book,title={Books}]
Your book titles are underlined, which is preventing line breaks (underlined text doesn't break). I don't think this is a standard behavior, book titles are usually displayed in italics. Perhaps you are using \underline{} inside your bibliography items definitions?

Why Bibliography and References appears in Latex TOC?

I am using these commands for including references:
\addcontentsline{toc}{chapter}{References}
\bibliographystyle{agsm}
\bibliography{dissrefs}
The problem is that in the table of contents both References and Bibliography appear, while I just want one to appear. Why is this happening? Can I customise the table of contents entry to be just one of them?
I am using MikTex 2.8 and TexMaker 2.1.
I dont think that you need to use \addcontentsline{toc} bibtex should do it automatically. At least I don't recall ever needing it...
Have you tried commenting out that line?
Edit regarding OPs comment on changing the title of the bibliography:
The bibliography's title can be changed by (to for instance "New Title") using \renewcommand\refname{New Title} for articles and \renewcommand\bibname{New Title} for books.
Instructions are read and processed in the order they appear, I think your problem is related to that order. Try moving things around (I believe that all settings should be put before \tableofcontents, but I'm not sure about that, I'v not used latex for a long time)

Referencing a theorem-like environment by its [name]

I am using ntheorem to typeset a set of conditions. In my preamble I have:
\theoremstyle{empty}
\newtheorem{Condtion}{Condtion}
When I want to typeset a condition, I write:
\begin{Condtion}[name]
\label{cnd:nm}
foo foo foo
\end{Condition}
The name appears boldface on the same line as the start of the text of the condition, with no number or anything. Perfect.
What I want to do now is refer to the condition by some variant of the \ref command,
\ref calls the number [which is not displayed anywhere else]
\thref writes "Condition n" for the nth condition
\nameref writes the name of the SECTION of the label.
a zref solution was suggested here, but seems unsatisfactory and unwieldly.
Any suggestions on a simple way to do this? (Even a simpler zref solution would be nice) At the moment I've just defined a \newcommand for each condition and use that rather than citing the condition itself. This is semantically opaque and just unsatisfying...
(edit: I emailed one author of ntheorem, Wolfgang May, and he explained that there isn't really a way to do this within ntheorem, since the [name] option isn't recorded.)
(edit: This isn't a dupe as suggested in the comment, since I'm interested in referencing an environment by its optional name command, not referencing the section/chapter it sits in.)
I think the following may do what you want.
\makeatletter
\def\namedlabel#1#2{\begingroup
\def\#currentlabel{#2}%
\label{#1}\endgroup
}
\makeatother
Then you use it as
\begin{theorem}
\namedlabel{thm:seamus}{Seamus' Theorem}
Here is Seamus' Theorem.
\end{theorem}
Here I reference~\ref{thm:seamus}.
Unfortunately, it can then only be referenced by name, though I suppose you could use a normal \label as well (with a different key of course).
For the amsthm environments you can use
\makeatletter
\let\#old#begintheorem=\#begintheorem
\def\#begintheorem#1#2[#3]{%
\gdef\#thm#name{#3}%
\#old#begintheorem{#1}{#2}[#3]%
}
\def\namedthmlabel#1{\begingroup
\edef\#currentlabel{\#thm#name}%
\label{#1}\endgroup
}
\makeatother
nameref doesn't work: it references the title of the SECTION the theorem-like environment appears in.
This is a nameref bug that was already fixed a while ago:
http://web.archiveorange.com/archive/v/9uUx5EuqoCGynIvx3om7#lY2MJxvge2oMgOi
Unfortunately some Linux distros like Debian/Ubuntu ship with horribly old versions of the packages (Ubuntu 11.04 still ships TeX Live 2009 although the latest version is TeX Live 2011). If you're using such a Linux distro stop using the Tex Live package in the distro, and install TeX Live directly from here: http://www.tug.org/texlive/ You can then update packages using tlmgr (a really cool tool that doesn't ship with Debian/Ubuntu).
you may want to check out the nameref package, which is distributed with hyperref. There is a section in the nameref documentation about referencing "stuff".
More on referencing can be found in the TeX FAQ item Referring to things by their name.
I thought others might find this helpful. Even though I had an updated hyperref package installed, I had to explicitly call \usepackage{nameref} after \usepackage{hyperref} in order to get the correct behavior from \nameref. Without the explicit call to \usepackage{nameref}, \nameref worked, but exhibited the bug discussed in this thread.
Update: this workaround isn't requred for a minimal example (which I checked). I don't know if there's something more complicated going on in my style files, but I'll update this if I find something. This may still help someone running into the same issue I was.

How to force line wrapping in listings package?

I have a problem concerning the listings package in latex. I need to embed a source code of the following XML document http://www.sparxsystems.com.au/downloads/profiles/EP_Extensions.xml in my master thesis' appendix. The problem is, no matter what options I pass to the package, I don't seem to be able to fit it on the page. The lines in the listing are too long, and the listings package doesn't wrap them, which seems odd... What combination of options will do the trick?
At the moment I use the following lstset instruction:
\lstset{
breakindent=0em,
language=XML,
basicstyle=\footnotesize,
numbers=left,
numberstyle=\footnotesize,
stepnumber=2,
numbersep=5pt,
backgroundcolor=\color{white},
showspaces=false,
showstringspaces=false,
showtabs=false,
frame=single,
tabsize=2,
captionpos=b,
breaklines=true,
breakatwhitespace=true,
breakautoindent=true,
escapeinside={\%*}{*)},
linewidth=\textwidth
}
Which, with no other options set, and combined with the following command:
\lstinputlisting{EP_Extensions.xml}
Lists the given file's source to the following output:
I just had this problem...
breaklines worked for me, though you do need to set it to true - the default is false:
\lstinputlisting[style=Python,
caption=My Class,
label={mine.py},
breaklines=true,
]{../python/mine.py}
is pretty much what I used
I had this problem and this page ranks highly on google so here was the solution for me:
I had the following inclusion: \usepackage[none]{hyphenat} which causes the issue described above. I was using it to fix the problem of latex automatically breaking lines in the middle of a word, which looks really stupid in some circumstances.
After much searching for an alternative to this solution I found nothing suitable and settled for properly broken lines but badly placed hyphenation.
Not a great answer, but one idea is to word wrap the source code before including it. If you're on linux, the command fold can be used for this. Clearly this works best if the text is in a fixed width font, which i would recommend in any case for code listings.
A followup to Aaron's answer. I was using basicstyle=\ttfamily for my listings. I was therefore able to permit line breaking by changing
\usepackage[none]{hyphenat}
to
\usepackage[htt]{hyphenat}
% ^^^
The hyphenat docs describe that the htt option "enables hyphenation of ... text typeset via either \texttt or \ttfamily." In my use case, I didn't see any hyphenation in my listings, but I did get the breaking.

Adding MS-Word-like comments in LaTeX

I need a way to add text comments in "Word style" to a Latex document. I don't mean to comment the source code of the document. What I want is a way to add corrections, suggestions, etc. to the document, so that they don't interrupt the text flow, but that would still make it easy for everyone to know, which part of the sentence they are related to. They should also "disappear" when compiling the document for printing.
At first, I thought about writing a new command, that would just forward the input to \marginpar{}, and when compiling for printing would just make the definition empty. The problem is you have no guarantee where the comments will appear and you will not be able to distinguish them from the other marginpars.
Any idea?
todonotes is another package that makes nice looking callouts. You can see a number of examples in the documentation.
Since LaTeX is a text format, if you want to show someone the differences in a way that they can use them (and cherry pick from them) use the standard diff tool (e.g., diff -u orig.tex new.tex > docdiffs). This is the best way to annotate something like LaTeX documents, and can be easily used by anyone involved in the production of a document from LaTeX sources. You can then use standard LaTeX comments in your patch to explain the changes, and they can be very easily integrated. If the document lives in a version control system of some sort, just use the VCS to generate a patch file that can be reviewed.
I have used changes.sty, which gives basic change colouring:
\added{new text}
\deleted{old text}
\replaced{new text}{old text}
All of these take an optional parameter with the initials of the author who did this change. This results in different colours used, and these initials are displayed superscripted after the changed text.
\replaced[MI]{new text}{old text}
You can hide the change marks by giving the option final to the changes package.
This is very basic, and comments are not supported, but it might help.
My little home-rolled "fixme" tool uses \marginpar where possible and goes inline in places (like captions) where that is hard to arrange. This works out because I don't often use margin paragraphs for other things. This does mean you can't finalize the layout until everything is fixed, but I don't feel much pain from that...
Other than that I heartily agree with Michael about using standard tools and version control.
See also:
Tips for collaboratively editing a LaTeX document (which addresses you main question...)
https://stackoverflow.com/questions/193298/best-practices-in-latex
and a self-plug:
How do I get Emacs to fill sentences, but not paragraphs?
You could also try the trackchanges package.
You can use the changebar package to highlight areas of text that have been affected.
If you don't want to do the markup manually (which can be tedious and interrupt the flow of editing) the neat latexdiff utility will take a diff of your document and produce a version of it with markup added to visually display the changes between the two versions in the typeset output.
This would be my preferred solution, although I haven't tested it out on large, multi-file documents.
The best package I know is Easy Review that provides the commenting functionality into LaTeX environment. For example, you can use the following simple commands such as \add{NEW TEXT}, \remove{OLD TEXT}, \replace{OLD TEXT}{NEW TEXT}, \comment{TEXT}{COMMENT}, \highlight{TEXT}, and \alert{TEXT}.
Some examples can be found here.
The todonotes package looks great, but if that proves too cumbersome to use, a simple solution is just to use footnotes (e.g. in red to separate them from regular footnotes).
Package trackchanges.sty works exactly the way changes.sty. See #Svante's reply.
It has easy to remember commands and you can change how edits will appear after compiling the document. You can also hide the edits for printing.

Resources