citep and citet not working even when using natbib package [closed] - latex

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.
Improve this question
I am writing a document in latex and I have a big .bib file and a large number of citations.
I want to have citations in the form [Author, year] format and am using the package natbib, but can't get citep or citet working, though plain cite is working fine. The error I get is:
! Undefined control sequence.
l.3 lets cite \citet{cayton05}
I am using Ubuntu texlive package and use \input{<file>} latex command to input the chapters to the main .tex file.
What's surprising is that instead of using \input{<file>} if I just have text in the main .tex file then all the cite commands are working.
Any help would be highly appreciated.
The working version is like this:
\usepackage{cite}
\usepackage[square,sort]{natbib}
%% lot of other packages and formatting %%
\begin{document}
\chapter{Testing citations}
\begin{enumerate}
\item this is the first citation \cite{belkin02}.
\item this is the second citation \citep{belkin02}.
\item this is the third citation \cite{shlens03}.
\end{enumerate}
\phantomsection\addcontentsline{toc}{chapter}{Bibliography}
\begin{spacing}{1.5}
\nocite{*}
\bibliographystyle{apalike}
\bibliography{testnb.bib}
\end{spacing}
\end{document}
In the real .tex file, I input the chapter text from another .tex file, and citep and citet won't work in that giving the aforesaid error, though plain cite will work fine.
I forgot to mention earlier I was using plain numbered bibliography style and everything was working, so there is no error in the input .tex files.

If \citep and \citet do not work, then you probably did not load natbib.
From a document I currently work on:
\usepackage[authoryear,round,longnamesfirst]{natbib}
You may want different options -- see the handy reference sheet for natbib for details.

You should only include \usepackage[square,sort]{natbib}.
It will work after deleting \usepackage{cite}.

Related

One link instead of two for \citep{} in LaTeX [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 11 months ago.
Improve this question
I'm writing some LaTeX for a document, and I'm using natbib for my citations, with the command \citep{ref}.
However, \citep is producing something like that (Author et al., Year), but 'Author et al.' and 'Year' are two separated links (pointing to the same reference).
I would like this to be only one link 'Author et al.,Year'.
How could I do that?
Thanks.
Found this answer here:
natbib and hyperref for (Author, Year) style produces two links
Which consists in adding to the preambule:
\makeatletter
\renewcommand\hyper#natlinkbreak[2]{#1}
\makeatother

How can I highlight text in latex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How can i highlit text in latex.
Thank you.
As is pictured here(in red circle):
If you mean making the text bold by Highlighting you can use \textbf for making the text bold but highlighting has a different general meaning that is implemented by \hl keyword.
\documentclass{report}
\usepackage{color} % for the command \textcolor
\usepackage{soul} % for the command \hl
\begin{document}
\hl{foo}
\hl{\textbf{foo}}
{my garden }
\textbf{black}{foo}
{my good job}
\textbf{\textcolor{red}{\hl{foo}}}
\textcolor{red}{\textbf{\hl{foo}}}
\end{document}
this is the result :
As you can see the word "black" is highlighted the way you desired.
The word "foo" is highlighted in the general meaning of highlighting.
This links look useful:
Insert symbols inside verbatim mode LaTeX
Putting math inside a verbatim environment without altering the formatting
If you just wanted graph.exe I would suggest using \begin{verbatim} graph.exe \end{verbatim} or \verb+graph.exe+ .
However you want to use the <..> expression which can be created with $ \langle ... \rangle $ . The $..$ indicates inline math mode. Those two links discuss getting verbatim text in math environments.
I think tex.stackexchange.com will be more helpful rather than stack overflow.

Disable page numbering converting markdown to pdf with pandoc [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 9 years ago.
Improve this question
I am converting a markdown file to pdf using pandoc. How can I suppress page numbers in the pdf file?
I will answer my own question here:
I learned in this post that pandoc markdown understands standard latex commands. Take for example the following markdown file called test.md:
% A pdf file without page numbers created from pandoc markdown
% sieste
% June 2013
\pagenumbering{gobble}
# First header
etc
and the command
pandoc test.md -o test.pdf
produces the desired pdf without page numbers.
I tried to use \pagestyle{empty} at first, but it did not work: If I put it where \pagenumbering{gobble} is now, page numbering is only turned off from page 2 on, and the first page is still numbered. And if I put it before the title block, the title in the pdf is messed up.

Ghostscript 9.07: Error: A pdfmark destimation ... points beyond the last page [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 9 years ago.
Improve this question
I use gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dFirstPage=$2 -dLastPage=$3 -sOUTPUTFILE=$4 $1 in a script to extract pages from a pdf file with Ghostscript 9.07. I obtain a lot of warnings (as in the first row in the following output) and one error:
GPL Ghostscript 9.07: **** Warning: Outline has invalid link that was discarded.
GPL Ghostscript 9.07: ERROR: A pdfmark destination page 4 points beyond the last page 3.
The resulting pdf (consisting of the extracted pages) is fine, however. I am wondering why I obtain this error and the warnings although I chose the option -q for quiet. I did some search on that and found, for example, this, but the pdf file is already generated with hypertexnames=false and so the suggested solution there does not work in my case (Ubuntu 13.04).
Just to add: The .pdf file is generated via pdflatex from:
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{tikz}
\usepackage{hyperref}
\begin{document}
\tikz[remember picture, overlay]\node at (current page.south)[rectangle, fill, color=gray]{};
\clearpage
\section{foo}
\clearpage
\tableofcontents
\clearpage
\section{bar}
foo bar
\end{document}
The original file contains named destinations (in this case the Outline tree) which point to a numbered page which will not be present in the final output file (because you have not chosen to include all the pages).
The destinations are therefore elided, which is why your output file works, and a warning is generated to tell you that some requested destinations will not be present.
The pdfwrite device pretty much ignores -q for these kinds of warnings, as we think they are important.

Remove spacing before \chapter in LaTeX [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 9 years ago.
Improve this question
I am using the book style to write a research report and would like to know how to remove the top vertical space before a chapter heading. I need this for the 'Abstract' page. I would like it to start nearer to the top than standard chapters.
Here is some sample code using the titlesec package, Stefan's suggestion. The titleformat command leaves everything at default values, but you need to include it (I think) for the titlespacing changes to work. The second titlespacing command sets back to default values, with assumption that you wanted altered spacing only for first chapter:
\documentclass{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
% this alters "before" spacing (the second length argument) to 0
\titlespacing*{\chapter}{0pt}{0pt}{40pt}
\begin{document}
\chapter{One}
% this changes "before" spacing back to its default of 50pt
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
First sentence of chapter.
\chapter{two}
First sentence of chapter.
\chapter{three}
First sentence of chapter.
\end{document}
An easy way is using the titlesec package. The appendix 9.2 of its documentation shows how the standard classes typeset their headings - it's not hard to copy and to modify those commands according to the own requirements.
Having the same issue, i tried out the titlesec solution, which somehow didn't work as expected (too many errors with Texshop 2.47 on OsX).
However, i worked out a simpler solution (at least for my case) with the geometry package. The deal is to call a new page geometry only for the page of interest and then restore the page geometry defined by fncychap.
% in the preamble
\documentclass[11pt,a4paper,twoside,openright]{book}
\usepackage{geometry}
\usepackage[Sonny]{fncychap}
% in the document
\frontmatter
% adapt geometry options to your needs
\newgeometry{textwidth=16cm,textheight=28cm,voffset=-2cm,bottom=0cm}
\chapter*{Abstract}
\markboth{}{}
\addcontentsline{toc}{chapter}{Abstract}
% text
\restoregeometry
% from now on fncychap takes over again
\mainmatter

Resources