how to make minted to do bold keywords? - latex

I would like to have bold font for minted rendered source code like in minted package manual. Currently keywords are in usual font.
\usepackage[table]{xcolor}
\usepackage{minted}
\definecolor{lightlightgray}{gray}{0.9}
\begin{document}
\begin{minted}
{cpp}
// class A
class A {
int boo;
};
\end{minted}
\end{document}
Result:

The problem is that there is no bold tt family in the Computer Modern Typewriter font. Try lmodern instead:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{minted}
\begin{document}
\begin{minted}{cpp}
// class A
class A {
int boo;
};
\end{minted}
\end{document}
See Using \ttfamily with \bfseries (or how to enable bold in fixed-width font) for details.

Related

Replace a single character in LaTeX?

I am using Linux Libertine as my font in my thesis and I love every character except for the italic uppercase J. However, the uppercase J in mathmode is nice and I would like to replace the italic J with the mathmode J. Is this possible? MWE:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\begin{document}
I do not like the italic \textit{J}, I want $J$ for that.
\end{document}
Output:
MWE compiled
I know that mathmode J is produced by the newtxmath package, whereas the italic J is provided by the libertine package itself.
Thank you in advance.

Title not being rendered with LaTeX

So I have the following document:
\include{preamble}
\title{test title}
\begin{document}
\maketitle
\begin{equation*}
\begin{aligned}
\pi\sqrt{\pi\sqrt{\pi\sqrt{\pi\sqrt{\pi\sqrt{\pi\dots}}}}}
\end{aligned}
\end{equation*}
\bibliographystyle{plain}
\bibliography{references}
\end{document}
the contents of my preamble.tex file is:
%%%%% Document Setup %%%%%%%%
\documentclass[10pt,onecolumn]{revtex4} % Font size (10,11 or 12pt) and column number (one or two).
\usepackage{times} % Times New Roman font type
\usepackage[a4paper, left=1.85cm, right=1.85cm,top=1.85cm, bottom=1.85cm]{geometry} % Defines paper size and margin length
\usepackage[font=small, labelfont=bf]{caption} % Defines caption font size as 9pt and caption title bolded
\usepackage{graphics,graphicx,epsfig,ulem} % Makes sure all graphics works
\usepackage{amsmath} % Adds mathematical features for equations
\usepackage{etoolbox} % Customise date to preferred format
\usepackage{subcaption}
\usepackage{caption}
\makeatletter
\patchcmd{\frontmatter#RRAP#format}{(}{}{}{}
\patchcmd{\frontmatter#RRAP#format}{)}{}{}{}
\renewcommand\Dated#name{}
\makeatother
\usepackage{fancyhdr}
\def\bibsection{\section*{References}} % Position reference section correctly
\usepackage{import}
\usepackage{pdfpages}
\usepackage{transparent}
\usepackage{xcolor}
\newcommand{\incfig}[2][1]{%
\def\svgwidth{#1\columnwidth}
\import{./figures/}{#2.pdf_tex}
}
\pdfsuppresswarningpagegroup=1
For some reason the title just will not be included on the pdf when I compile the code, I am sure I have \title{} and \maketitle in the correct positions. Any help as to why this is would be much appreciated.
Move the title after \begin{document}:
\documentclass{revtex4}
\begin{document}
\title{test title}
\maketitle
\end{document}
(don't do this with other documentclasses. Most of the time it is better to have the \title in the preamble, e.g. to get sensible pdf meta data if combined with hyperref)

Redefine \footnote to change color of index in Latex

For my work I shall make it possible to change the color of the footnote index optionally.
I found a way to change the color, but it is not flexible.
\RequirePackage{xcolor}
\definecolor{red}{RGB}{165,30,55}
\renewcommand{\thefootnote}{\textcolor{red}{\arabic{footnote}}}
\begin{document}
a footnote\footnote{lalala}
\end{document}
this works. But this does not:
\renewcommand{\thefootnote}[1]{\textcolor{#1}{\arabic{footnote}}}
\begin{document}
a footnote\footnote[red]{lalala}
\end{document}
I think it is because \footnote already has one optional parameter for the index number.
Is there a way to change it?
With a new command, one could do something like this:
\documentclass{article}
\RequirePackage{xcolor}
\newcommand{\cfootnote}[2][black]{%
{\color{#1}\footnote{#2}}%
}
\begin{document}
a footnote\cfootnote{lalala}
a footnote\cfootnote[red]{lalala}
\end{document}
Another approach with redefining the footnote:
\documentclass{scrartcl}
\usepackage{scrletter}
\usepackage{xcolor}
\let\oldfootnote\footnote
\usepackage{xparse}
\usepackage{etoolbox}
\RenewDocumentCommand{\footnote}{ O{} m O{black}}{%
\deffootnotemark{\color{#3}\textsuperscript{\thefootnotemark}}%
\ifstrempty{#1}{%
\oldfootnote{#2}%
}{%
\oldfootnote[#1]{#2}%
}
}
\begin{document}
test\footnote{text}[red]
test\footnote{text}
test\footnote[42]{text}
test\footnote[42]{text}[blue]
\end{document}

How do I remove the List of Figures from the Tables of Contents in Latex?

I'm using the report class, and I have a table of contents that I would like to start with the introduction. However I'd also like the List of Figures to come after the contents, but not be included in the contents itself.
However at the moment the contents looks like this:
Contents
List of Figures vi
1 Introduction 1
I'd like to still have the LoF after the contents, but I just want it to not appear in the ToC, is this possible?
\documentclass[a4paper, 9pt]{report}
\usepackage{graphicx}
\usepackage[margin=1.0in]{geometry}
\usepackage{sectsty}
\usepackage{url}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{fancyvrb}
\usepackage{pdfpages}
\usepackage{longtable}
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{mathpazo} % Palatino font
\usepackage[nottoc,numbib]{tocbibind}
\renewcommand{\bibname}{References}
\chapternumberfont{\Large}
\chaptertitlefont{\huge}
\graphicspath{ {images/} }
\lstset{
basicstyle=\small\ttfamily,
columns=flexible,
breaklines=true
}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\begin{document}
\pagenumbering{roman}
\begin{titlepage}
\end{titlepage}
\chapter*{Authorship Declaration}
\chapter*{Acknowledgements}
\chapter*{Abstract}
\tableofcontents
\listoffigures
\chapter{Introduction}
It seems that the use of asterisk just after \listoffigures (or \newpage if you are using it) removes the list of figures from the table of contents. Of course the same is valid for the list of tables.
At least it worked for me.

Adding the abstract to the front page in Latex

Included below is my LaTeX code. By default the abstract is on the first page following the title page. But the title page has lots of space below, and my abstract will be short, so is there anyway to include it below the title page components?
code:
\documentclass[12pt,reqno,a4paper,titlepage]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssybm}%for math bold
\usepackage[pdftex]{graphicx}
\usepackage{verbatim}
\usepackage[margin=2.5cm]{geometry}%for the margins headers footers etc
\usepackage{hyperref}%for the hyperlinks-COOL and must use
\usepackage[tt]{titlepic}%package i downloaded to put a pic in the titlepage
\usepackage{helvet}
\usepackage[usenames,dvipsnames]{color}%options to use names like redviolet and others
\begin{document}
\title{title}
\titlepic{\setlength\fboxsep{0pt}\setlength\fboxrule{4pt}
\fcolorbox{Plum}{green}{\includegraphics[scale=0.3]{pic}}}
\author{\Huge my name}
\maketitle
\begin{abstract}
abstract text here
\end{abstract}
document text here
\end{document}
Wrap your title page to minipage
\begin{minipage}[h]{\textwidth}
\maketitle
\end{minipage}
Then you can add text below it.

Resources