Generalapalike bibliography style comes out w/ no parenthesis

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
rawlins02
Posts: 22
Joined: Tue Oct 07, 2008 6:56 pm

apalike bibliography style comes out w/ no parenthesis

Post by rawlins02 »

Two problems to resolve. I'm using
pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6). Newly installed on Ubuntu linux system.

In the past, and as I've seen documented, apalike bibliography style worked as documented. Now it's now producing output of the citation in text with no parenthasis, like this: Smith et al. 2008, rather than (Smith et al., 2008). Below I've pasted the apalike.sty file I'm using. Could there be a problem with this file? How best to resolve? Simple modification to that file or could there more a more insidious problem here.

Next, when using \ref to reference Table numbers in same article document, the Table numbers I'm getting with \ref{tab:string} linked to the \label{string} in table environment are always exactly equal to the number of \section that I have in the document.

Thanks in advance.
Mike

% apalike.sty style, used in conjunction with apalike.bst,
% will produce an apa-like bibliography style:
%
% 1) Bibliography entries formatted alphabetically, last name
% first, each entry having a hanging indentation and no label.
% 2) References in the following formats:
% (Author, 1986)
% (Author and Author, 1986)
% (Author et al., 1986).
% 3) Multiple references in the form (Author1, 1986; Author2, 1987)
%
% To be used as an optional argument to the \documentstyle command; for example
% \documentstyle[11pt,apalike]{book}
%
% 16-Sep-86, original version by Susan King and Oren Patashnik.
% 13-Oct-87 changes:
% Fixed bug in last line by adding the {} that disappeard when
% the \hbox{} was removed from the pre-APALIKE definition;
% added club and widow penalties;
% patched the \newblock LaTeX bug from `-.07em' to simply `.07em';
% and made this work for document styles that don't define `chapter'.
%
%
% Use parens instead of brackets for \cite, and no label in the bibliography
%
\def\@cite#1#2{#1\if@tempswa , #2\fi}
\def\@biblabel#1{}

% Set length of hanging indentation for bibliography entries
%
\newlength{\bibhang}
\setlength{\bibhang}{2em}

% \thebibliography environment depends on whether or not `chapter's can exist
%
\@ifundefined{chapter}{\def\thebibliography#1{\section*{References\@mkboth
{REFERENCES}{REFERENCES}}\list
{\relax}{\setlength{\labelsep}{0em}
\setlength{\itemindent}{-\bibhang}
\setlength{\leftmargin}{\bibhang}}
\def\newblock{\hskip .11em plus .33em minus .07em}
\sloppy\clubpenalty4000\widowpenalty4000
\sfcode`\.=1000\relax}}%
{\def\thebibliography#1{\chapter*{Bibliography\@mkboth
{BIBLIOGRAPHY}{BIBLIOGRAPHY}}\list
{\relax}{\setlength{\labelsep}{0em}
\setlength{\itemindent}{-\bibhang}
\setlength{\leftmargin}{\bibhang}}
\def\newblock{\hskip .11em plus .33em minus .07em}
\sloppy\clubpenalty4000\widowpenalty4000
\sfcode`\.=1000\relax}}

% `; ' goes between cites, and there's no \hbox around individual cites
%
\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
\def\@citea{}\@cite{\@for\@citeb:=#2\do
{\@citea\def\@citea{; }\@ifundefined
{b@\@citeb}{{\bf ?}\@warning
{Citation `\@citeb' on page \thepage \space undefined}}%
{\csname b@\@citeb\endcsname}}}{#1}}

Recommended reading 2024:

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

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

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

apalike bibliography style comes out w/ no parenthesis

Post by Juanjo »

rawlins02 wrote: In the past, and as I've seen documented, apalike bibliography style worked as documented. Now it's now producing output of the citation in text with no parenthasis, like this: Smith et al. 2008, rather than (Smith et al., 2008). Below I've pasted the apalike.sty file I'm using. Could there be a problem with this file? How best to resolve? Simple modification to that file or could there more a more insidious problem here.
It seems to me that apalike.sty is an obsolete package. You should load natbib. This package provides commands to obtain different styles of citation. You may need the \citep command. Read the documentation.
rawlins02 wrote: Next, when using \ref to reference Table numbers in same article document, the Table numbers I'm getting with \ref{tab:string} linked to the \label{string} in table environment are always exactly equal to the number of \section that I have in the document.
Surely you have written the \label command before \caption. Just write \label after \caption:

Code: Select all

\begin{table}[table_placement]
   \centering
   \begin{tabular}{column_descriptors}
      tabular stuff
   \end{tabular}
   \caption{Text} \label{tab:mylabel}
\end{table}
Feel free to ask again if you still have any doubt.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
rawlins02
Posts: 22
Joined: Tue Oct 07, 2008 6:56 pm

apalike bibliography style comes out w/ no parenthesis

Post by rawlins02 »

Thanks. Natbib working better. I'm now looking into \bibpunct. I'll also try Makebst to customize form of the references. Right now year is coming out near end of reference and I'd like, as a default, to have the year appear in either brackets or parenthesis, immediately after authors.

As for Tables problem no, I correctly have \label after \caption:

Code: Select all

 

\documentclass [12pt] {article}
\usepackage{graphicx}
\usepackage{array,alltt,amsmath,rotating}
\usepackage{setspace}     % make document double space
%\usepackage{cite}            % allow latex to break citations to avoid overfull
\sloppy                      % allow wide inter-word spacing
\usepackage{indentfirst}
\usepackage{tabularx}
\usepackage{natbib}

\doublespacing

\begin{document}

\section{Introduction}

Figure~\ref{fig:Q36_99}

Figure~\ref{fig:Q36_65}a, Table~\ref{tab:seasonalQ}

Figure~\ref{fig:Q36_65}b, Table~\ref{tab:seasonalQ}

Figure~\ref{fig:Q2periods}

Figure~\ref{fig:prcp_annQ_trends}


%  ****  UNCOMMENTING SOME OF THESE SECTION CALLS WILL SHOW HOW
%  ****  THE TABLE NUMBER PRODUCED WITH \ref{tab:string} IS SHOWN
%  ****  AS THE SAME NUMBER OF SECTION CALLS. THE ABOVE CALL
%  ****  \ref{tab:seasonalQ} IS PRODUCING A '3' RIGHT NOW. 

%\section{Annual and Seasonal River Discharge} \label{sec:discharge}

%\section{Precipitation and Discharge Trends Across Subbasins of the OYL}
%\section{X}
%\section{Y}
%\section{Z}

\section{Conclusions} \label{sec:conclusions}


\section{Acknowledgments}


\bibliographystyle{plainnat}
%\bibliographystyle{amsplain}
\bibliography{../biblio}


\clearpage


\begin{figure}
\begin{center}
\includegraphics*[keepaspectratio=true,width=0.65\hsize,angle=270,draft=false] {example.eps}
\end{center}
\caption{} 
\label{fig:Q36_99}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics*[keepaspectratio=true,width=0.6\hsize,angle=270,draft=false] {example.eps}
\end{center}
\caption{}
\label{fig:Q36_65}
\end{figure}


\begin{figure}
\begin{center}
\includegraphics*[keepaspectratio=true,width=0.7\hsize,angle=270,draft=false] {example.eps}
\end{center}
\caption{}
\label{fig:Q2periods}
\end{figure}


\begin{table} [p]
\begin{center}
\begin{tabular}{|l|r@{.}l|r@{.}l|r@{.}l|r@{.}l|r@{.}l|r@{.}l|} 
\hline
\multicolumn{1}{|l|} { }  &
\multicolumn{6}{c|} {1936--1965} &
\multicolumn{6}{c|} {1966--1995} \\ % \hline
\multicolumn{1}{|l|} {River Basin} &
\multicolumn{2}{c|} {Winter} &
\multicolumn{2}{c|} {Spring} &
\multicolumn{2}{c|} {Summ./Fall} &
\multicolumn{2}{c|} {Winter} &
\multicolumn{2}{c|} {Spring} &
\multicolumn{2}{c|} {Summ./Fall} \\ \hline \hline
%%& (mm yr$^{-1}$) & (mm yr$^{-1}$) & (mm yr$^{-1}$) & (year) & (mm yr$^{-1}$) \\ \hline
Ob & 0&10 &  0&06 &  $-$0&25 &  0&14 &  \textbf{0}&\textbf{16} &  \textbf{$-$0}&\textbf{66}  \\ \hline
Yenisey &  $-$0&05 &  $-$0&23 &  $-$0&26 &  \textbf{0}&\textbf{63} &  0&36 &  $-$0&09 \\ \hline
Lena &  \textbf{0}&\textbf{13} &  0&14 &  0&27 &  \textbf{0}&\textbf{24} &  $-$0&06 &  $-$0&20 \\ \hline
Combined &  \textbf{$-$0}&\textbf{06} &  $-$0&01 &  $-$0&10 &  \textbf{0}&\textbf{33} &  0&16 &  \textbf{$-$0}&\textbf{34} \\ \hline

\end{tabular}
%\end{center}
\caption{}
\end{center}
\label{tab:seasonalQ}
%\end{sidewaystable}
\end{table}


\begin{figure}
\begin{center}
\includegraphics*[keepaspectratio=true,width=0.8\hsize,angle=270,draft=false] {example.eps}
\end{center}
\caption{} 
\label{fig:prcp_annQ_trends}
\end{figure}


\end{document}

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

apalike bibliography style comes out w/ no parenthesis

Post by Juanjo »

rawlins02 wrote: As for Tables problem no, I correctly have \label after \caption:

Code: Select all

 
.................

\begin{table} [p]
\begin{center}
\begin{tabular}{|l|r@{.}l|r@{.}l|r@{.}l|r@{.}l|r@{.}l|r@{.}l|} 
   
   (tabular stuff removed)

\end{tabular}
%\end{center}
\caption{}
\end{center}
\label{tab:seasonalQ}
%\end{sidewaystable}
\end{table}
Sorry, but you haven't correctly \label after \caption, since the former is inside a center environment and the latter is outside it. Follow the scheme I gave above. Put \label right after \caption. It is also better to use \centering instead of the center environment (this saves vertical space).
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
rawlins02
Posts: 22
Joined: Tue Oct 07, 2008 6:56 pm

apalike bibliography style comes out w/ no parenthesis

Post by rawlins02 »

Thank you Juanjo. Table referencing now works correctly. So that's two issues resolved, one to go.

Can you please suggest how to improve this table. There are 7 columns. I see, as I intended, left justified for columns 1 and 2 and center (decimal aligned) for columns 3 and 4. Column 5 also OK. How do I make numerical values line up under the column headings for columns 6 and 7, which are also to be decimal aligned. I also can't seem to get the missing vertical lines on right side of table headings. Any other general suggestions to improve appearance greatly appreciated. Apologies if not starting a separate thread is incorrect here...

Code: Select all


\begin{table} [p]
\centering
\begin{tabular}{|llr@{.}lr@{.}lrr@{.}lr@{.}l|}
\hline
{Station Name} & Basin  & \multicolumn{2}{c}{Lat} & \multicolumn{2}{c}{Lon} & Area & \multicolumn{2}{c}{TrendP} & \multicolumn{2}{c}{TrendQ} \\
  &  &  \multicolumn{2}{c}{$^{\circ}N$}  & \multicolumn{2}{c}{$^{\circ}E$}  &  km$^{2}$  &  \multicolumn{2}{c}{mm season$^{-2}$} & \multicolumn{2}{c}{mm season$^{-2}$} \\ \hline \hline
Tom' At Tomsk   & Ob  &   56&50  &   84&92  & 57000 & 1&35 &  -2&83 \\
Katun' At Srostky & Ob   &   152&42  &   185&72  & 58400 & -2&01 &  -1&11\\
\end{tabular}
\caption{Caption text...} \label{tab:riversubbasins}
\end{table}

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

apalike bibliography style comes out w/ no parenthesis

Post by Juanjo »

You may want to use the dcolumn package, which deals precisely with columns requiring alignment at the decimal point. Concerning the missing vertical lines, write c| instead of c as the descriptor in the last \multicolumn of every row. Anyway, many people (not me) considers that vertical lines are completely innecessary in tables. The author of the booktabs package thinks so. This package provides suitable horizontal lines, leaving enough vertical space from the surrounding rows.

Whether or not you use vertical lines, you may try to get a not so tight table, increasing the vertical space between rows. Just before \begin{tabular} add \renewcommand{\arraystretch}{1.4}. By default this parameter is 1. The greater its value is, the more space between rows you get. See also the \extrarowheight length defined in the array package.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

apalike bibliography style comes out w/ no parenthesis

Post by localghost »

You can achieve better decimal alignment by using the dcolumn package. The following example translates most of the suggestions from Juanjo.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{array,booktabs,dcolumn,textcomp}

\parindent0em
\newcolumntype{d}{D{.}{.}{-2}}

\begin{document}
  \begin{table}[!p]
    \centering
    \caption{Caption text...} \label{tab:riversubbasins}
    \begin{tabular}{llddcdd} \toprule
      Station Name & Basin  & \multicolumn{1}{c}{Lat} & \multicolumn{1}{c}{Lon} & Area & \multicolumn{1}{c}{TrendP} & \multicolumn{1}{c}{TrendQ} \\
      &  &  \multicolumn{1}{c}{\textdegree N} & \multicolumn{1}{c}{\textdegree E} &  \multicolumn{1}{c}{km\textsuperscript{2}} & \multicolumn{1}{c}{mm season\textsuperscript{-2}} & \multicolumn{1}{c}{mm season\textsuperscript{-2}} \\ \midrule[1pt]
      Tom' At Tomsk & Ob & 56.50 &  84.92  & 57000 & 1.35 &  -2.83 \\ \midrule
      Katun' At Srostky & Ob & 152.42 & 185.72 & 58400 & -2.01 & -1.11 \\ \bottomrule
    \end{tabular}
  \end{table}
\end{document}
Perhaps this fits better your ideas. More information is given by the documentations of the used packages.


Best regards and welcome to the board
Thorsten¹
rawlins02
Posts: 22
Joined: Tue Oct 07, 2008 6:56 pm

Re: apalike bibliography style comes out w/ no parenthesis

Post by rawlins02 »

Thanks Thorsten. The table you posted is what I'd envisioned. I've been looking at the dcolumn documentation and struggling a bit getting tabular working right. Part of the problem is likely inexperience with tabular environment. But I also found the dcolumn document on CTAN to be lacking somewhat in examples---examples with all command to make different tables. I'd be interested in any other resources which show examples of the use of dcolumn package. This table you sent may just be the example I needed...

Mike
Post Reply