Text FormattingSpecial Modifications to Bibliography Style

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Special Modifications to Bibliography Style

Post by cgnieder »

I downloaded v6.01 of apacite and still couldn't reproduce your error until I changed the class from article to book. It seems there have been some changes to the conditionals. I adapted the above code with the relevant parts of the definition of \thebibliography in v6.01 which then compiled without errors:

Code: Select all

\listfiles
\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage[doublespacing]{setspace}
\usepackage{apacite}
\usepackage{lipsum}  % not for use in the actual document

% Original code taken from "apacite.sty" v6.01
\makeatletter
\def\thebibliography#1{%
  \@ifundefined{chapter}%
    {\st@rtbibsection}%
    {\@ifundefined{@sectionbibtrue}%
       {\@ifundefined{@mainmatterfalse}%
          {\st@rtbibchapter}%
          {\if@mainmatter
             \st@rtbibsection
           \else
             \st@rtbibchapter
           \fi
          }%
       }%
       {\if@sectionbib
          \st@rtbibsection
        \else
          \st@rtbibchapter
        \fi
       }%
    }%
  \bibliographytypesize % e.g., to put the bibliography in \small type
  \bibliographyprenote  % some explanatory note before the references
  \@ifundefined{APAC@metaprenote@\APAC@extra@b@citeb}%
    {}% skip
    {\csname APAC@metaprenote@\APAC@extra@b@citeb\endcsname}%
  \list{\relax}{\singlespacing
                \labelsep=\biblabelsep
                \parsep=\bibparsep
                \itemsep=\bibitemsep
                \leftmargin=\bibleftmargin
                \itemindent=\bibindent}% changed to cope with 4th ed.
   \def\newblock{\hskip .11em plus .33em minus .07em}%
   \sloppy\clubpenalty10000\widowpenalty10000
   \sfcode`\.=1000\relax %'
   \bt@beg@thb@hook
   \APACrestorebibitem
}
\setlength{\bibitemsep}{%
  \ifcase \@ptsize \relax % 10pt
    0.6\baselineskip%
  \or % 11pt
    0.618\baselineskip%
  \or % 12pt
    0.604\baselineskip%
  \fi%
}
\show\if@sectionbibdefault
\makeatother

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@book{ShipingOutWhere,
  author = "H. Shipping",
  title = "Expert Deliveries",
  edition = "",
  publisher = "Silly Dogcourt",
  address = "Boston",
  year = "1978"
}

@book{Shu1980,
  author = "D. F. Shu and J. S. Mikey",
  title = "Introduction to Small Packages",
  edition = "",
  publisher = "Lackluster University",
  address = "New York",
  year = "1980"
}

@book{SnowEssentials,
  author = "I. P. Snow",
  title = "The Nighttime Extortionist",
  edition = "3",
  publisher = "Bucksport Company",
  address = "San Francisco",
  year = "1990"
}

@book{Zambaba1,
  author = "T. Zambaba",
  title = "Mega Laughanormous",
  edition = "2",
  publisher = "The Mafia",
  address = "Hoboken, New Jersey",
  year = "1997"
}

@book{SnowOrigins,
  author = "I. P. Snow",
  title = "The Nighttime Extortionist Microwaves a Light Bulb",
  edition = "9",
  publisher = "Bucksport Company",
  address = "San Francisco",
  year = "1999"
}

@book{BeeVomit,
  author = "E. T. BeeVomit",
  title = "The Honeycomb Matrix",
  edition = "",
  publisher = "Cambridge University Press",
  address = "",
  year = "1999"}

@book{WFartmann,
  author = "W. Fartmann",
  title = "Booze \& Plans 4 Tomorrow",
  edition = "6",
  publisher = "Dub Pub",
  address = "Miami, Florida",
  year = "1999"
}

@book{ChaseMax,
  author = "C. E. Max and J. E. Orive",
  title = "Myths about the Speed Demons on the Road",
  edition = "",
  publisher = "Benjamin Cummings",
  address = "San Francisco",
  year = "2001"
}

@book{Fix2004,
  author = "N. E. Fix and I. Paeyoo",
  title = "Lots of Money: If You Screw Me I Find You",
  edition = "",
  publisher = "McGraw--Hill",
  address = "New York",
  year = "2004"
}

@book{Lewiston,
  author = "W. Lewiston",
  title = "Mastery of the Internet: From Process to Production",
  edition = "4",
  publisher = "Online Press",
  address = "Everywhere",
  year = "2004"
}

@book{HTwCentry,
  author = "N. Hester and L. Blimey and W. Chesire",
  title = "The Colours of the Online Environment",
  edition = "4",
  publisher = "Chesire Company",
  address = "London",
  year = "2007"
}

@book{Schx1,
  author = "L. Schx and M. Savage",
  title = "Delivery from Dementia: an Extension of the Never-Motionless Mind",
  edition = "3",
  publisher = "McGraw--Hill",
  address = "New York",
  year = "2007"
}

@book{BenDoverReturns,
  author = "B. Dover and D. Nine",
  title = "When I Am Fixated on the Premature Mind I Dream about Long Titles",
  edition = "",
  publisher = "Boston Private Press",
  address = "Boston",
  year = "2012"
}

@book{JJCreeper,
  author = "I. C. U. Creeper",
  title = "How to creep around the house on tip toes and socks",
  edition = "",
  publisher = "Nighttime Illumination",
  address = "Atlanta, Georgia",
  year = "2010"
}

@book{FreeMe,
  author = "U. N. I. R. Free and I. M. Me",
  title = "Releaving your Old Self and Not Caring about the Mistakes You Make Along the Way",
  edition = "2",
  publisher = "House of Pride",
  address = "New York",
  year = "2011"
}

@book{Lini,
  author = "S. Lini and F. Lini",
  title = "Confusion about Commuting through the Fast Paced Cities",
  edition = "2",
  publisher = "Sickamore International",
  address = "Seattle",
  year = "2011"
}
\end{filecontents*}

\bibliographystyle{apacite}

\begin{document}
  \lipsum[1]  % not for use in the actual document
  \nocite{*}

  \bibliography{\jobname}
\end{document}
Regards
site moderator & package author

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Special Modifications to Bibliography Style

Post by LavaTyper »

It works! Finally... I applied it to my full project and it all works beautifully.

Having said that, my background with LaTeX is not as expertise as yours (as in, what are all these log files...meh I'll just ignore them), so this is why I really needed help here. Much appreciated.

I'm also surprised that v6.01 and v6.03 would be so different to cause such problems.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Special Modifications to Bibliography Style

Post by cgnieder »

LavaTyper wrote:Having said that, my background with LaTeX is not as expertise as yours (as in, what are all these log files...meh I'll just ignore them)
Most of the time you actually can ignore them. Many of those are auxiliary files for the processing, most notably the aux file that contains (not only) information on labels for example, or the toc file that contains the actual table of contents.

The files you shouldn't ignore are the logging files such as log and blg (the bibliography log file). They often contain valuable information when errors happen...
LavaTyper wrote:I'm also surprised that v6.01 and v6.03 would be so different to cause such problems.
The differences in the case at hand aren't so big, actually, they're supposed to be minor internal code anyway. But if you start hacking on it then the version is important :)

Regards
site moderator & package author
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Special Modifications to Bibliography Style

Post by Johannes_B »

LavaTyper wrote:once again the above example does not work for me.
... It does not work.

Here is my attached log and resulting PDF file...after I accept the error messages that I get.
And you didn't wonder about the errors? It is working perfectly on my machine, and Thorsten said the same thing. You didn't upload a log file (well, you did, but much later than i requested) ...

But i am glad to hear, that it now works.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Special Modifications to Bibliography Style

Post by LavaTyper »

Johannes_B wrote:
LavaTyper wrote:once again the above example does not work for me.
... It does not work.

Here is my attached log and resulting PDF file...after I accept the error messages that I get.
And you didn't wonder about the errors? It is working perfectly on my machine, and Thorsten said the same thing. You didn't upload a log file (well, you did, but much later than i requested) ...

Why do you insist on arguing with me? How was I supposed to know what to do with the files when I have so little experience with LaTeX? I asked for help, not to be trapped in an argument. This is the second time that you're acting like this to me.
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Special Modifications to Bibliography Style

Post by LavaTyper »

Updated request

The code that cgnieder provided almost works, but for my project I need to have everything be left justified, and no hyphenation.

So, I have \usepackage[document]{ragged2e} and \usepackage[none]{hyphenate} in the preamble.

Everything seems fine... except... some entries in the bibliography have unacceptably long spaces. For my project, I need to remove inconsistent spacing.



Help:

In the minimal working example, below, there is an error with the last cited entry in the bibliography. There is a large space between "Z. (1997)" and also between "(1997). This" - for my project, which has about 100 entries, I need to have consistent spacing.


How do I fix this issue?


(Also see attached screenshot - to illustrate what I mean)

Code: Select all

\documentclass[12pt]{book}
\usepackage[document]{ragged2e}
\usepackage[none]{hyphenat}
\usepackage[T1]{fontenc}
\usepackage[doublespacing]{setspace}
\usepackage{apacite}
\usepackage{lipsum}  % not for use in the actual document

% Original code taken from "apacite.sty" v6.01
\makeatletter
\def\thebibliography#1{%
  \@ifundefined{chapter}%
    {\st@rtbibsection}%
    {\@ifundefined{@sectionbibtrue}%
       {\@ifundefined{@mainmatterfalse}%
          {\st@rtbibchapter}%
          {\if@mainmatter
             \st@rtbibsection
           \else
             \st@rtbibchapter
           \fi
          }%
       }%
       {\if@sectionbib
          \st@rtbibsection
        \else
          \st@rtbibchapter
        \fi
       }%
    }%
  \bibliographytypesize % e.g., to put the bibliography in \small type
  \bibliographyprenote  % some explanatory note before the references
  \@ifundefined{APAC@metaprenote@\APAC@extra@b@citeb}%
    {}% skip
    {\csname APAC@metaprenote@\APAC@extra@b@citeb\endcsname}%
  \list{\relax}{\singlespacing
                \labelsep=\biblabelsep
                \parsep=\bibparsep
                \itemsep=\bibitemsep
                \leftmargin=\bibleftmargin
                \itemindent=\bibindent}% changed to cope with 4th ed.
   \def\newblock{\hskip .11em plus .33em minus .07em}%
   \sloppy\clubpenalty10000\widowpenalty10000
   \sfcode`\.=1000\relax %'
   \bt@beg@thb@hook
   \APACrestorebibitem
}
\setlength{\bibitemsep}{%
  \ifcase \@ptsize \relax % 10pt
    0.6\baselineskip%
  \or % 11pt
    0.618\baselineskip%
  \or % 12pt
    0.604\baselineskip%
  \fi%
}
%\show\if@sectionbibdefault
\makeatother

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@book{ShipingOutWhere,
  author = "H. Shipping",
  title = "Expert Deliveries",
  edition = "",
  publisher = "Silly Dogcourt",
  address = "Boston",
  year = "1978"
}

@book{Shu1980,
  author = "D. F. Shu and J. S. Mikey",
  title = "Introduction to Small Packages",
  edition = "",
  publisher = "Lackluster University",
  address = "New York",
  year = "1980"
}

@book{SnowEssentials,
  author = "I. P. Snow",
  title = "The Nighttime Extortionist",
  edition = "3",
  publisher = "Bucksport Company",
  address = "San Francisco",
  year = "1990"
}

@book{Zambaba1,
  author = "Z. Zambaba",
  title = "This is an example of an entry that produces {LongSpacesBetweenWords}",
  edition = "2",
  publisher = "The Mafia",
  address = "Hoboken, New Jersey",
  year = "1997"
}

@book{SnowOrigins,
  author = "I. P. Snow",
  title = "The Nighttime Extortionist Microwaves a Light Bulb",
  edition = "9",
  publisher = "Bucksport Company",
  address = "San Francisco",
  year = "1999"
}

@book{BeeVomit,
  author = "E. T. BeeVomit",
  title = "The Honeycomb Matrix",
  edition = "",
  publisher = "Cambridge University Press",
  address = "",
  year = "1999"}

@book{WFartmann,
  author = "W. Fartmann",
  title = "Booze \& Plans 4 Tomorrow",
  edition = "6",
  publisher = "Dub Pub",
  address = "Miami, Florida",
  year = "1999"
}

@book{ChaseMax,
  author = "C. E. Max and J. E. Orive",
  title = "Myths about the Speed Demons on the Road",
  edition = "",
  publisher = "Benjamin Cummings",
  address = "San Francisco",
  year = "2001"
}

@book{Fix2004,
  author = "N. E. Fix and I. Paeyoo",
  title = "Lots of Money: If You Screw Me I Find You",
  edition = "",
  publisher = "McGraw--Hill",
  address = "New York",
  year = "2004"
}

@book{Lewiston,
  author = "W. Lewiston",
  title = "Mastery of the Internet: From Process to Production",
  edition = "4",
  publisher = "Online Press",
  address = "Everywhere",
  year = "2004"
}

@book{HTwCentry,
  author = "N. Hester and L. Blimey and W. Chesire",
  title = "The Colours of the Online Environment",
  edition = "4",
  publisher = "Chesire Company",
  address = "London",
  year = "2007"
}

@book{Schx1,
  author = "L. Schx and M. Savage",
  title = "Delivery from Dementia: an Extension of the Never-Motionless Mind",
  edition = "3",
  publisher = "McGraw--Hill",
  address = "New York",
  year = "2007"
}

@book{BenDoverReturns,
  author = "B. Dover and D. Nine",
  title = "When I Am Fixated on the Premature Mind I Dream about Long Titles",
  edition = "",
  publisher = "Boston Private Press",
  address = "Boston",
  year = "2012"
}

@book{JJCreeper,
  author = "I. C. U. Creeper",
  title = "How to creep around the house on tip toes and socks",
  edition = "",
  publisher = "Nighttime Illumination",
  address = "Atlanta, Georgia",
  year = "2010"
}

@book{FreeMe,
  author = "U. N. I. R. Free and I. M. Me",
  title = "Releaving your Old Self and Not Caring about the Mistakes You Make Along the Way",
  edition = "2",
  publisher = "House of Pride",
  address = "New York",
  year = "2011"
}

@book{Lini,
  author = "S. Lini and F. Lini",
  title = "Confusion about Commuting through the Fast Paced Cities",
  edition = "2",
  publisher = "Sickamore International",
  address = "Seattle",
  year = "2011"
}
\end{filecontents*}

\bibliographystyle{apacite}

\begin{document}
  \lipsum[1]  % not for use in the actual document
  \nocite{*}

  \bibliography{\jobname}
\end{document}
Attachments
Spacing.jpg
Spacing.jpg (110.33 KiB) Viewed 12368 times
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Special Modifications to Bibliography Style

Post by cgnieder »

If you don't allow hyphenation then you don't gain much with ragged2e. In fact it causes what you're experiencing here. In standard LaTeX \raggedright sets \rightskip to 0pt plus 1fil which means the space to the right is allowed to stretch infinitely. With ragged2e \raggedright sets \rightskip to 0pt plus 2em.

Solution to your case seems to be not to use ragged2e and place \raggedright at the beginning of your document.

Regards
site moderator & package author
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Special Modifications to Bibliography Style

Post by LavaTyper »

That seemed to work, but then I ended up with that same spacing issue in my table of contents. I've just decided to use both ragged2e and \raggedright.
Post Reply