How can I tweak the numbering inside the appendices environment? - latex

I have the following structure in my Latex book:
1) main file
...
\include{chapter1}
\include{chapter2}
\include{chapter3}
...
2) chapterN.tex
\input{file1}
\input{file2}
\input{file3}
\begin{appendices}
\input{appendix_1_chapterN}
\input{appendix_2_chapterN}
\end{appendices}
The result is that the appendixes at the end of chapter 1 (for instance) is named ".1" and ".2", when I would like them to be name "1.A" and "1.B".
Any help is appreciated.

The answer to this is covered in the documentation to the appendix package, which is required for the appendices environment that you are using: ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/appendix/appendix.pdf
The answer to your question is that you are using the appendices environment for section appendices, where it is designed for chapter appendices. To achieve your goal of section appendices, use the subappendices environment instead as shown below:
\documentclass{book}
\usepackage{appendix}
\begin{document}
\chapter{Intro}
\section{Intro Sec}
\begin{subappendices}
\section{Appendix Sec}
\end{subappendices}
Some Text
\chapter{Conclusion}
Some Text
\end{document}

Related

latex in text citations error: citation undefined

I am wanting to do in text citations for my dissertation. I will upload a simplified version of what i am seeing. The issue is that i keep getting "undefined citations" where i only get the citation key out in my pdf irrespective of which compiler i use.
I also keep getting an error saying that the bibliography is empty. But when my friend uses the exact code i have and copies the references and everything into his overleaf environment it works. I could not get it working with miktex and texmaker. Please help
I have checked a lot of articles of what is available and i swear im following what they are doing but i cant get any further
Initially, my idea is to pull the citations from another file because ill be using these citations in multiple documents. I have successfully setup the .bib file which will update as i add more references to Zotero (my reference manager). I tried to pull citations from the .bib file by coding in the file directory, but no luck there.
I then tried to not use the "file directory approach" and just have a references file in the same folder as the .tex file. But that didnt work either.
my code is as follows:
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage[style=ieee]{biblatex}
\addbibresource{refs.bib} %%updated from References.bib
%document headings
\title{Practice}
\author{Justin Smith}
\begin{document}
%Cover Page
\maketitle
\textbf{This page represents the cover page}\newline
\textit{Report will begin here}
\thispagestyle{empty}
\pagebreak
%Introduction
\section{Introduction}
The introduction for the report will be inserted here
\pagebreak
%end Introduction
%Literature Survey
\section{Literature Survey}
\subsection{Referencing Examples}
This section serves to use a reference and understand how to implement references as well as generate a reference list at the end of this report.\\
The citation test \cite{schmidtPreprocessingMethodologyEnhance2019}\\
\pagebreak
%Reference List
\section*{Reference List}
%%\bibliographystyle{IEEE}
%%\bibliography{C:/Users66smi/OneDrive/University of Pretoria/Zotero/MyZoteroLibrary.bib}
%%\printbibliography[title = Reference List]
%%\bibliography{MyZoteroLibrary.bib}
\end{document}
EDIT:
Upon trying to do what #celdor initially said said i still run into the same issue. The following screenshots add to the initial question.
Screenshot showing code and issue directly
Screenshot showing Latex "Configure" settings
From the Log file, the following logs detail relevant warnings
LaTeX Warning: Citation 'schmidtPreprocessingMethodologyEnhance2019' on page 3
undefined on input line 36.
Underfull \hbox (badness 10000) in paragraph at lines 36--37
[]
[3]
LaTeX Warning: Empty bibliography on input line 39.
(Latex test.aux)
LaTeX Warning: There were undefined references.
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex) "Latex test"
(biblatex) and rerun LaTeX afterwards.
Package logreq Info: Writing requests to '"Latex test".run.xml'.
\openout1 = `"Latex test.run.xml"'.
)
Extra information:
The following screenshots are of the Project folder
First, latexsym is an old package superseded by amssymb. I looked at the file and its last update was in 1998!
As to your issues, assuming your text file is main.tex, try the following:
Clean your project folder from all auxiliary *.aux; the best way to do that is to issue latexmk -C in your project folder.
Additionally, remove main.bbl
make sure your *.bib file is in the root project folder
add backend=biber to list of options of biblatex.
Then, run:
pdflatex main.tex # or xelatex main.tex or lualatex main.tex etc.
biber main
pdflatex main.tex # see above
Without *.bbl file, the first run of pdflatex does not produce any reference list and latex may issue a warning. With an old *.bbl file, you will get wrong citations. After the whole sequence is executed, main.pdf should have the correct citation and a reference list.
Remember \bibliography is incompatible with biblatex. The correct macro to create bibliography list is \printbibliography. It will issue \section* in article or \chapter* in report/book for a title and format it according to settings in a document class.
Here, I created References.bib with a dummy article:
#ARTICLE{schmidtPreprocessingMethodologyEnhance2019,
author = {Other, Anthony Norman},
title = {Some things I did},
year = {2014},
journal = {J.~Irrep. Res.},
volume = {1},
number = {1},
pages = {1-10}
}
and run the code as suggested, and frankly I get expected results without any errors!
The full code:
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{amssymb} %superseds latexsym
\usepackage{graphicx}
\usepackage[backend=biber,style=ieee]{biblatex}
\addbibresource{References.bib}
%document headings
\title{Practice}
\author{Justin Smith}
\begin{document}
%Cover Page
\maketitle
\textbf{This page represents the cover page}\newline
\textit{Report will begin here}
\thispagestyle{empty}
\pagebreak
%Introduction
\section{Introduction}
The introduction for the report will be inserted here
\pagebreak
%end Introduction
%Literature Survey
\section{Literature Survey}
\subsection{Referencing Examples}
This section serves to use a reference and understand how to implement references as well as generate a reference list at the end of this report.\\
The citation test \cite{schmidtPreprocessingMethodologyEnhance2019}\\
\clearpage
\printbibliography[title = Reference List]
\end{document}
and here's the screenshot:
The answer as suggested by #samcarter_is_at_topanswers.xyz
is that I was not using biber.
To do this on textmaker proceed to Options/Configure Textmaker. A configuration window will appear. Under the Commands Window locate "Bib(la)tex" and set the designation to "biber %". This will solve the issue.
Setting Update
A similar procedure can be followed on texstudios
See the below link on how to make sure textmaker uses this setting for reference.
https://tex.stackexchange.com/questions/44040/biblatex-biber-texmaker-miktex
thank you for everyones efforts in solving this problem.

Unsuccessful changing 'Chapter' to 'Annex'

I am trying to change the title 'Chapter' in appendices into 'Annex' but am unable to do so. I looked up and found the solution as
\renewcommand\appendixname{Annex}
but this does not solve my problem and the title still shows as 'Chapter'.
My guess is it might be because I have changed the titleformat of the chapters (or it might not be because of it....)
If someone could help me with the issue. My code in the preamble looks like:
\usepackage[titletoc]{appendix}
\titleformat{\chapter}[display]
{\normalfont\LARGE\bfseries\center}{Chapter \thechapter}{0.3em}{\LARGE}
\titlespacing*{\chapter}{0pt}{-15pt}{15pt}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\titleformat{\section}
{\normalfont\fontsize{14}{10}\bfseries}{\thesection}{1em}{\fontsize{14}{10}}
\renewcommand{\appendixname}{Annex}
\begin{document}
All contents that matters.....
\begin{appendices}
\chapter{Some Annex}
\input{Chapters/Appendix}
\end{appendices}
\end{document}
The problem is that you hardcoded the word Chapter here:
\titleformat{\chapter}[display]
{\normalfont\LARGE\bfseries\center}{Chapter \thechapter}{0.3em}{\LARGE}
To use the right word, regardless of whether you're in the main content or in the appendices, use \chaptertitlename as documented in the titlesec package documentation (page 4):
\chaptertitlename
It defaults to \chaptername except in appendices where it is \appendixname. Use it instead of \chaptername when defining a chapter.
Remember to add {} to make the trailing space significant:
\titleformat{\chapter}[display]
{\normalfont\LARGE\bfseries\center}{\chaptertitlename{} \thechapter}{0.3em}{\LARGE}

How to link to a glossary item (using package glossaries)

In my document i'm using the package glossaries to create a glossary. Everything works fine except that the is no link between the words in the text and the corresponding entry in my glossary (so you can click the word to be explained and get to the glossary entry).
The most important parts of my document:
%----Header----
...
\usepackage[nonumberlist,acronym,toc,style=altlist]{glossaries}
\usepackage[
colorlinks=true,
pdfborder=0 0 0,
pdfpagelabels,
plainpages=false,
linktocpage=false,
pdfcreator={LaTeX}]{hyperref}
...
%Glossary entries
\newglossaryentry{glos:twitter}{name=Twitter,
description={Mikroblogging-Service.}}
%----Main document----
\begin{document}
\chapter{Introduction}
This text is a normal glossary item: \gls{glos:twitter}.
This text should also link to the glossary item: \glslink{glos:twitter}{Link to Twitter}
but there is no link
...
\printglossary
\end{document}
As you see i'm also using the package hyperref, but there seems to be no mechanism that automatically links words in the main text to the glossary.
I also tried to use \ref and \label, but this doesnt' work when the element that is referred is outside the main document (like my glossary is).
I'm using the makeglossaries-script coming from miktex (calling makeglossaries main on build), but this also doesn't give me a link.
Anyone knows a way to do that? Or maybe i should use another package than glossaries which supports a functionality like that?
I would also appreciate any working examples where this functionality works.
EDIT:
I just got a working minimal example where gls/glslink actually works. Seems like the linking of glossary items interfers with one of the packages im using in my document. Will have to try by adding my packages one by one to the example to see which package is the reason. The example:
\listfiles
\documentclass{article}
\usepackage[
colorlinks=true,
pdfborder=0 0 0,
pdfpagelabels,
plainpages=false,
linktocpage=false,
pdfcreator={LaTeX}]{hyperref}
\usepackage[nonumberlist,acronym,toc,style=altlist,]{glossaries}
\makeglossaries
%Glossary entries
\newglossaryentry{glos:twitter}{name=Twitter,
description={Mikroblogging-Service.}}
%----Main document----
\begin{document}
\chapter{Introduction}
Ein normales Wort aus dem Glossar: \gls{glos:twitter}.
Dieses Wort soll zum Glossar verlinkt werden: \glslink{glos:twitter}{Link to Twitter}
funktioniert aber nicht...
\clearpage
\printglossary
\end{document}
As not mentioned in the extract of my latex-code, in my documentclass, the draft property was set to true. When removing this property or setting it to false, the gls/glslink work fine.

How do I create a new Beamer environment with a verbatim environment?

I'm creating a Beamer presentation that has a lot of example LaTeX in it, which has to go in a verbatim environment. I'm getting tired of typing
\begin{example}
\begin{verbatim}
Verbatim Text
\end{verbatim}
\end{example}
I wish to create a new command or environment that will shorthand this for me. I also need this for blocks and theorems, since I'm using those frequently as well. But if I can figure it out for examples, it should be easy to translate to another example.
I can't create a new environment or command using just \begin{verbatim}, since it cuts off the rest of the command. So I switched to using the fancyvrb package, and tried the following:
\DefineVerbatimEnvironment
{MyVerbatim}{Verbatim}{}
\newcommand{\makeexample}[1]{
\begin{example}
\begin{MyVerbatim}
#1
\end{MyVerbatim}
\end{example}
}
\makeenvironment{VerbExample}{\begin{example}
\begin{MyVerbatim}}{\end{MyVerbatim}\end{example}}
That gives me the \makeexample{Example Text} command, and the \begin{VerbExample}...\end{VerbExample} environment, but they both still throw errors on compile. The frame I'm trying to use them in looks like this (I've got the [fragile] option on the frame, so it's not that).
\begin{frame}[fragile]
\frametitle{Why Doesn't Verbatim Work?}
\makeexample{Verbatim Text}
\begin{VerbExample}
Verbatim Text
\end{VerbExample}
\end{frame}
Environment definition:
\newenvironment{VerbExample}
{\example\semiverbatim}
{\endsemiverbatim\endexample}
Frame definition:
\begin{frame}[fragile]
\frametitle{Title}
\begin{VerbExample}
test test test $t$ $\\omega$
test test
\end{VerbExample}
\end{frame}
Verbatim cannot go inside \newcommand. Semiverbatim is defined by Beamer and works well with it. The three characters \ { } must be escaped as \\ \{ \}.
Source: Beamer user guide, pp. 119-120
http://www.ctan.org/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf

header width on the last page of the chapter

I'm trying to turn off marginpar when starting a new multicols environment with this new environment, which uses the multicols and chngpage packages:
\newenvironment{multi}[1]{%
\newlength{\newtextwidth}%
\setlength{\newtextwidth}{\marginparwidth}%
\addtolength{\newtextwidth}{-1cm}%
\addtolength{\headheight}{.5cm}%
\let\oldheadrule\headrule%
\addtolength{\headwidth}{\newtextwidth}%
\begin{adjustwidth}{}{-\newtextwidth}\begin{multicols}{#1}}%
{\end{multicols}\end{adjustwidth}}
Which works great:
latex header http://img6.imageshack.us/img6/6757/screenshotewa.png
Uhm, almost, since on the last page of the current chapter "Lorem ipsum" it behaves like I hadn't instruct it to: \addtolength{\headwidth}{\newtextwidth}:
latex header at the end of the chapter http://img11.imageshack.us/img11/6072/screenshotwbd.png
How could I fix that?
Edit:
I'm also using fancyhdr.
2nd Edit:
A PoC:
\documentclass[12pt,a4paper,oneside]{report}
\usepackage[utf8]{inputenc}
\usepackage[top=2cm,left=2cm,right=4.5cm]{geometry}
\usepackage{chngpage}
\usepackage{color}
\usepackage{amsmath}
\usepackage[pdftex,bookmarks,pdfpagemode=UseOutlines,bookmarksopen,backref
,colorlinks,urlcolor=blue,linktocpage]{hyperref}
\usepackage{url}
\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage{indentfirst}
\usepackage{listings}
\usepackage{boxedminipage}
\pagestyle{fancy}
\setlength{\columnseprule}{1pt}
\setlength{\marginparwidth}{4cm}
\rhead{\large\leftmark}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\makeatletter
\renewcommand*\#makechapterhead[1]{%
{\parindent \z# \raggedright \normalfont
\huge\bfseries
#1\par\nobreak
\vskip 20\p#
}}
\makeatother
\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\-\oldmarginpar[\sffamily\raggedleft\footnotesize #1]%
{\sffamily\raggedright\footnotesize
\begin{boxedminipage}{\marginparwidth}#1\end{boxedminipage}
}}
\newenvironment{multi}[1]{%
\newlength{\newtextwidth}%
\setlength{\newtextwidth}{\marginparwidth}%
\addtolength{\newtextwidth}{-1cm}%
\addtolength{\headheight}{.5cm}%
\let\oldheadrule\headrule%
\addtolength{\headwidth}{\newtextwidth}%
\begin{adjustwidth}{}{-\newtextwidth}\begin{multicols}{#1}}%
{\end{multicols}\end{adjustwidth}}
\begin{document}
\tableofcontents
\chapter{Lorem ipsum}
\begin{multi}{2}
\lipsum[1-20]
\end{multi}
\chapter{Lorem ipsum}
\begin{multi}{2}
\lipsum[1-20]
\end{multi}
\chapter{Lorem ipsum}
\begin{multi}{2}
\lipsum[1-20]
\end{multi}
\end{document}
It should be possible to continue single-column on the same page, after "multi", but the headers must be kept like when the page was started within the "multi" environment.
Why would I need single-column after multi-column on the same page with a marginpar? Imagine presenting the source code for the article, with small hints on the margin. (That's what the listing package is there for)
I suspect your last heading box is being constructed after your text finishes making the multicol boxes, so you're out of the scope of your change. It goes back to the old value.
You'd probably do well to add the fancyhdr package and use it. I believe it's well-behaved in multicolumn.
Okay, so it's almost certainly the scope thing. You're doing the adjustwidth in your new multi environment. When your text runs out in the multi envirnment, you haven't filled the last page; headers aren't set up until the page is filled. So your mutlti environment finishes the box, you leave the scope, and THEN the page is finished and emitted. Using the old width.
Set the header width and parameters outside the environment.
I ran your test document. It seems to have a bug in that \newlength{\newtextwidth} has a global effect, and so causes an error. Not sure why that is but I pulled it out of the \newenvironment{multi} with no ill effect.
Charlie's diagnosis is definitely correct. An alternative solution is to end the page after the multicols but before the adjustwidth, thus:
\newenvironment{multi}[1]{%
...}
{\end{multicols}\vfill\break\end{adjustwidth}}
I have tested this solution and on your sample document, it produces good output.

Resources