suppress section numberings in nbconvert to latex? - latex

Is it possible with nbconvert --> latex --> PDF to suppress section numberings?
Essentially I would like to keep the simple font size distinctions that the markdown header syntax (#, ##, etc.), and ipynb section headings provide (nbconvert --to latex appears to treat these same), and still use these to define section headings, but without the numberings. Then I also have the option of adding my own numbers manually.
I can cope with losing some aspects of general latex document structuring and functionality. Ideally though I would like to keep that information, and just suppress the numberings in the PDF.
Cheers.

You can simply use the stared version of the LaTeX heading tags (section*, subsection*).
To do so, you have to create a custom template (e.g. secnum.tplx) which could look like the following
for IPython 1.x:
((*- extends 'latex_article.tplx' -*))
((* block h1 -*))section*((* endblock h1 -*))
((* block h2 -*))subsection*((* endblock h2 -*))
((* block h3 -*))subsubsection*((* endblock h3 -*))
((* block h4 -*))paragraph*((* endblock h4 -*))
((* block h5 -*))subparagraph*((* endblock h5 -*))
for IPython 2.x:
((*- extends 'article.tplx' -*))
((* block h1 -*))\section*((* endblock h1 -*))
((* block h2 -*))\subsection*((* endblock h2 -*))
((* block h3 -*))\subsubsection*((* endblock h3 -*))
((* block h4 -*))\paragraph*((* endblock h4 -*))
((* block h5 -*))\subparagraph*((* endblock h5 -*))
for IPython 3.x:
As IPython 3.x removed the heading cell type these approaches are no longer applicable here.
((* extends 'article.tplx' *))
((* block commands *))
\setcounter{secnumdepth}{0} % Turns off numbering for sections
((( super() )))
((* endblock commands *))
Note that stared headings will not be present in the TOC.
To use these templates, call them during the conversion like
ipython nbconvert --to=latex --template=secnum.tplx file.ipynb

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.

org mode how to convert code block into latex format?

org-mode block code, i want to convert to latex with beautiful format.
The fllow org-mode text, when convert to latex file, it's so ugly. how should i
do?
#+begin_src c
#inlcude <stdio.h>
int main(int argc, char **argv)
{
printf("hello\n");
}
#+end_src
For formatting the code, try
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\usepackage[scaled=.85]{beramono}
\lstset{
language=C,
backgroundcolor=\color{black!5}, % set backgroundcolor
basicstyle=\footnotesize\ttfamily,% basic font setting
columns=fullflexible,
}
\begin{document}
\begin{lstlisting}
int main(int argc, char **argv)
\end{lstlisting}
\end{document}
which gives
Hope this helps!
Try this:
\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[language=C]
int main(int argc, char **argv)
\end{lstlisting}
\end{document}
listings package can be used to various languages. It put the keywords in bold.
You should use:
\begin{lstlisting}[frame=single]
if you want a frame around the code
You should use:
\lstset{language=C,morekeywords={filter},deletekeywords={main}}
\begin{lstlisting}[frame=single]
if you want to put more words in bold (in example the word filter will be shown in bold) or if you want to put a C keyword in normal font (in example: main will not be shown in bold)

how to make minted to do bold keywords?

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.

How to disable numbering in latex?

I am new to latex and I wrote the below tex code on Texmaker editor.
What I want to do is to add the "University" section without any numbering preceeding it and to be centered horizontally, because when I run the code I find that the word "University" is displayed but it is preceeded by a number and I do not want to display any number preceeding that word.
code:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{kpfonts}
\author{Anan}
\pagestyle{plain}
\begin{document}
\section{University}
\end{document}
\section*{\centering University}
% * removes numbering for _this_ \section instance,
% \centering within environment centres the title.
Note however, that this is a local solution, and that it's better practice (and easier for you to make later document-global changes) to re-define the \section, \subsection, ... environments using the titlesec package, as is described well in Alan Munn:s answer in the following tex.stackexchange thread:
https://tex.stackexchange.com/questions/8546/section-heading-centering-problem
All you have to do is to edit your line 9:
\section{University}
this way:
\section*{\centering University}
since the command \section* produces unnumbered sections.
Further, if you want to to include an unnumbered section to your table of contents, you can add
\addcontentsline{toc}{section}{University}
(this time without \centering) just after. The resulting code:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{kpfonts}
\author{Anan}
\pagestyle{plain}
\begin{document}
\tableofcontents
\section*{\centering University}
\addcontentsline{toc}{section}{University}
Text.
\end{document}

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