I am writing a document class for LaTeX and I want it to be generic. In this document class I redefine the \maketitle command to display a custom title page, and here I want to display some information, like the title, author, etc., but also some other informations. Here is how I display the title:
{\LARGE{\bf \#title}}\\
I'd like to create a new command that works similarly to \title or \author, how can I do that?
If you look at latex.ltx you can see that \title is defined as follows:
\def\title#1{\gdef\#title{#1}}
\def\#title{\#latex#error{No \noexpand\title given}\#ehc}
Those are low-level TeX commands. \title is a command that redefines \#title to expand to the argument given to \title. In more modern LaTeX commands your own definition could look like this:
\newcommand\foo[1]{\renewcommand\#foo{#1}}
\newcommand\#foo{\#latex#error{No \noexpand\foo given}\#ehc}
It's better to use \PackageError or \ClassError to show the error message. Or, if you want \foo to be optional and be empty by default:
\newcommand\foo[1]{\renewcommand\#foo{#1}}
\newcommand\#foo{}
If this is not inside a package, you'll have to put it between \makeatletter and \makeatother because of the # signs.
Here is a sample command I used in my thesis.cls class. It defines a new command \university that works as the \title or \author commands with a default value equals to "no university". If I don't use the \university command in my preamble the default value will be used instead.
\def\#university{no university}
\newcommand{\university}[1]{
\def\#university{#1}
}
Then, in the \maketitle command you can have something like:
\newcommand{\maketitle}{
{\LARGE{\bf \#title}}\\
{\small{\#university}}\\
}
Related
I would like to export a text document which uses the exam class to markdown. To do so, I am currently using a workaround which was suggested in this answer, which relies on pseudo-definitions which in turn overwrite the definitions of the exam class such that pandoc can produce a clean markdown file.
Although, the workaround works for the suggested multiple-choice questions, I cannot adopt the solution to work for text with “fillin gaps” such as the document below:
\documentclass[answers]{exam}
\usepackage{minted}
\let\oldpart\part
\renewcommand{\part}[1][]{\oldpart[#1]{}}
\begin{document}
\begin{questions}
\question Exercise 1
\begin{parts}
\part[1] This fills in the \fillin[blanks][3cm]
\end{parts}
\end{questions}
\end{document}
If I use the following pseudo-definitions in a separate file:
% ignore \part
\renewcommand{\part}[0][1]{}
% Treat checkboxes like an itemized list
\newenvironment{checkboxes}{\begin{itemize}}{\end{itemize}}
\renewcommand{\CorrectChoice}{\item ☒ }
\renewcommand{\choice}{\item ☐ }
\renewcommand\fillin[2][{}]{\textbf{#1}}
I get the following broken markdown output
This fills in the **blanks**3cm\]
Moreover is there a way for pandoc to ignore \begin{parts} and \end{parts} so that there are no ::: in the final Markdown file?
The \fillin problem can be solved with
\newcommand{\fillin}[1][1]{\textbf{#1}\noop}
whereas the parts div can be removed with
\newenvironment{parts}{}{}
I've learnt how to use LaTeX at the user level, but wanted to package the recurring code (resulting mostly from the styling of the cover) in a class file.
Therefore, I tried the following simple example class file:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2018/10/12 v0.1 Test class]
\PassOptionsToClass{12pt}{report}
\ProcessOptions
\LoadClassWithOptions{report}
Although this works if I pass the size I want, if I omit it, it defaults to 10pt, instead of 12pt that I want. Do you know how to make the default become the 12pt, and still work if I decide to give it another size option?
Based on https://tex.stackexchange.com/a/123623/36296 you could so something like
\RequirePackage{filecontents}
\begin{filecontents}{test.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test}[2018/10/12 v0.1 Test class]
\DeclareOption{10pt}{\def\test#ptsize{10pt}}
\DeclareOption{11pt}{\def\test#ptsize{11pt}}
\DeclareOption{12pt}{\def\test#ptsize{12pt}}
\ExecuteOptions{12pt}
\ProcessOptions
\PassOptionsToClass{\test#ptsize}{report}
\LoadClass{report}
\end{filecontents}
\documentclass{test}
\begin{document}
test
\end{document}
I'm producing a set of documents in LaTeX, and I would like to provide a single, global bibliography page for the whole set. This is because each document is page-limited: I don't want to take up space with references at the bottom of each one.
This means in each case, I would like to cite in the text, but not produce a reference at the end. I am using bibtex/natbib to handle the referencing.
Simplest example:
\documentclass[]{article}
\bibliographystyle{/usr/share/texmf/bibtex/bst/natbib/plainnat.bst}
\usepackage{natbib}
\begin{document}
In \citet*{MEF2010} I described the method.
\bibliography{bibliography.bib}
\end{document}
How can I do this? Essentially I just want it to cite correctly:
In Bloggs, Blagg and Blog (2010) I described the method.
But not add a references section at the end. Any ideas?
Thanks,
David
Instead of using \bibliography{bibliography.bib} you can try \nobibliography{bibliography.bib}.
You still need to enter the path so it can make the cross-references.
It happens due to missing packages. If you want to resolve the problem then enable the automatic installation packet. After that,First, you run the BibTeX file and generate the Pdf file (instead of pdfLatex file) and then pdfLatex to Pdf
I'm typesetting my CV using the europecv LaTeX class. I don't actually need to conform to the EU's standardized CV form, but I like the general layout of it. One thing that bothers me about the class is how it sets certain headings, for instance
Surname(s) / First name(s): Smith, John
Where I'd rather have
Name: John Smith
I've found that these string constants for English are defined in a file called "ecven.def" thus:
\def\ecv#infosectionkey{\ecv#utf{Personal information}}
\def\ecv#namekey{\ecv#utf{Surname(s) / First name(s)}}
\def\ecv#addresskey{\ecv#utf{Address(es)}}
\def\ecv#telkey{\ecv#utf{Telephone(s)}}
\def\ecv#mobilekey{\ecv#utf{Mobile}}
I guess I could just edit this file to change them, but that seems like the wrong approach. I tried to do this at the top of my document:
\renewcommand{\ecv#namekey}{\ecv#utf{Name}}
which gives this error:
./eurocv.tex:22: LaTeX Error: Missing \begin{document}.
And I've tried this:
\def\ecv#namekey{\ecv#utf{Name}}
which doesn't give an error, but doesn't change the output. Any ideas?
You need to use the \makeatletter and \makeatother commands wrapping your changes.
\makeatletter
\def\ecv#namekey{\ecv#utf{Name}}
...
\makeatother
I'd like to use LaTeX's \tableofcontents command (or some equivalent) to automatically generate a table of contents, but I'd also like to add a sentence or two to each line in the table of contents that describes what the referenced section is about. How can I do this?
The tocloft package and its \cftchapterprecistoc command solved my problem.
Try
\addcontentsline{toc}{section}{sample text}
Follwoing Oliver and simon's advice:
You could redefine the sectioning commands to take a second (possibly optional) argument, and use that to build your argument to \addtocontentsline, and then involk the cooresponding section* command.
I expect you can brute force and ignorance something using addcontentsline.
eg:
\addcontentsline{toc}{section}{text}
however, this will conflict with automagically generated lines if you don't use the starred versions of sections it refers to.
Anything more clean will require messing about with the relevant macros....unless I'm missing something.
I would change the {section} part to {subsection}.
\addcontentsline{toc}{subsection}{sample text}