Including a decimal in a Latex section number - latex

I'm trying to get my latex sections to be labeled 1.0, 2.0 instead of 1, 2. Is there an easy way to do this or some way to define the specific numbers I want sections to be numbered?
EDIT:
I have this basic outline:
\documentclass[12pt]{article}
\begin{document}
\section{first}
\subsection{second}
\end{document}
I currently see:
1 first
1.1 second
I would like:
1.0 first
1.1 second

This should do the trick for you. Add the following lines to the preamble:
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}
EDIT:
Changed from document type book to document type article. i.e. chapter replaced with section and section replaced with subsection.
EDIT:
Thanks for pointing out the \arabic command! I edited my answer accordingly.

Related

How to left align a whole table in markdown (pandoc)?

How do you left align an entire table in Markdown/Pandoc? I know about different ways of specifying tables and how alignment of columns are done, but I cannot find a way to shift the table from center aligned to left aligned (have even tryed embedding <div style="float: left>..</div> which didn't work). Do I have to switch to LaTeX to do this? I will export to pdf later on, if that makes a difference.
I now found a solution to this problem at tex.stackexchange.com. Apparently pandoc inserts \centering for every float in the document. This can be cancelled by inserting \let\centering\relax in a custom preample to pandoc (as pandoc argument -H custompreample.tex). The link also describes more detailed ways to for example define different floats for tables and figures.
I've found this solution here.
a simple \usepackage in header-includes: that looks doing the job itself...
- \usepackage[margins=raggedright]{floatrow}
I hope it won't have side effects. Currently, on my pandoc generated pdfs, none, but I don't know its boundaries.
it has at least one limit: it applies upon every table of your pdf, and not a single one, if it's what you were looking for.
I was not able to get the solutions here to work--in LaTeX. I created a new longtable environment to make tables the way I wanted them. That was easier in the end. Here's an example Rmd file.
---
title: "Custom table"
header-includes:
- \usepackage{longtable,booktabs}
output: pdf_document
---
\newenvironment{mylong}
{\begin{longtable}[l]{p{.25in}p{3in}p{3in}}Line & Statements & Reasons\\
\toprule\addlinespace }
{ \addlinespace\bottomrule\end{longtable} }
\begin{mylong}
1& $a+b=a+d$ & Given P10, if $b=d$, then 1 is true\\
2& $a+b=c$ & Given\\
3& $a+d=c$ & Given P9, if 1 and 2 are true, then 3 is true. QED\\
\end{mylong}

How do I keep my section numbering in Latex but just hide it?

I need something like this:
Chapter 1
Preliminaries
1.1 Banach Algebras
I tried this:
\chapter{}
\section*{Preliminaries}
\subsection{Banach Algebras}
The problem is: As soon as I hide the section number using \section*{Preliminaries}, it changes the numbering of the subsection to 0.1 Banach Algebras.
How do I hide the number of the section but keep the number ordering in my subsection?
A quick fix without the hassles of renewing the section command is to use addtocounter.
Everytime you use the \section*{} command, right after that you can say \addtocounter{section}{1}
\chapter{}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
This will give you a result of,
Chapter 1
Preliminaries
1.1.1 Banach Algebras
Preliminaries
1.2.2 Banach Algebras
Essentially, it is just adding 1 to your section counter whenever you create a section so when the subsection checks the section counter, it has the updated counter.
And the advantage is that if you add another section now which needs to be numbered like,
\chapter{}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
\section*{Preliminaries}
\addtocounter{section}{1}
\subsection{Banach Algebras}
\section{Preliminaries}
You will get the correct section number (i.e. 1.3)
Chapter 1
Preliminaries
1.1.1 Banach Algebras
Preliminaries
1.2.2 Banach Algebras
1.3 Preliminaries
The main drawback is that you will have to remember to add to the counter everytime you created a \section*{}
You can add \setcounter{subsection}{0} everytime you create one of those sections to reset the subsection counter... sorry I missed that one.
Thanks for clarifying.
So you just don't want to see the number displayed? Just use \renewcommand to renew the \section command, as thus:
\renewcommand{\thesection}{}
If you're using KOMA-script document classes (e.g., scrartcl), include in your preamble
\renewcommand*{\sectionformat}{}
The same goes for \subsectionformat, \subsubsectionformat, \paragraphformat, and \subparagraphformat, to whatever depth you've set with \setcounter{secnumdepth}{}. Though you've hidden the counter label, the counter counts the section anyway and includes it in TOC and bookmarks. (Tested with hyperref and bookmark packages loaded.)
This same question is asked here, and its accepted answer by #zwol works just like I wanted.
I think your best bet is to redefine \thesection, which is the macro
that normally prints the section number.
\renewcommand\thesection{}
If you want subsection numbers to include the section numbers that
aren't getting printed, you will also need to redefine
\thesubsection, which normally calls \thesection:
\makeatletter
\renewcommand\thesection{}
\renewcommand\thesubsection{\#arabic\c#section.\#arabic\c#subsection}
\makeatother

How can I attach a LaTeX marker to an arbitrary place in text?

Is it possible to attach a marker to just a place in text, not to section, sub-section, etc.?
This is what I'm trying to achieve:
\begin{document}
Alex (see~\ref{alex}) is a boy,
Jessica (see~\ref{jessica}) is a girl.
[...]
\label{alex}\ref{alex}: Alex Johnson: 4 y.o.
\label{jessica}\ref{jessica}: Jessica D.: 5 y.o.
\end{document}
I want to get something like this:
Alex (see 1) is a boy,
Jessica (see 2) is a girl.
[...]
1: Alex Johnson: 4 y.o.
2: Jessica D.: 5 y.o.
Makes sense?
This is the solution:
\newcounter{foo}
Alex (see~\ref{alex}) is a boy,
Jessica (see~\ref{jessica}) is a girl.
[...]
\refstepcounter{foo}\thefoo\label{alex}: Alex Johnson: 4 y.o.
\refstepcounter{foo}\thefoo\label{jessica}: Jessica D.: 5 y.o.
Posted by Will at https://tex.stackexchange.com/questions/4021/how-to-set-a-marker-counter-label-to-an-arbitrary-piece-of-text
If you want to have a label, consider the following (from here);
\label{marker} You give the object you want to reference a marker, you can see it like a name.
\ref{marker} You can reference the object you have marked before. This prints the number that was assigned to the object.
\pageref{marker} It will print the number of the page where the object is.
Normally, if you reference to a label, LaTeX prints out the section, subsection, etc. But if you want to specify the exact place in text, you can use pageref. So with pageref you can exactly print out the page number of the "marker".
This is - as far as i know - the most exact possibility to tell the reader where in text a "marker" was, i.e. it is - as far as i know - impossible to tell LaTeX to print the exact line number or so.
You can use \label anywhere, including in the body of the text, but the thing labelled will be (roughly) the 'current labellable thing', that is the last \*section, or the current equation or table.
If you want to label something else (what is it you're after?) then you'll have to roll your own (not trivial), and have something which, if I recall correctly, sets \#currentlabel.
Edited, to add:
\begin{document}
\section{Hello}
Here is some text
\label{l1}
More text.
\newpage
Further text, on page 2
\label{l2}
This is section~\ref{l1} on page~\pageref{l1}.
And section~\ref{l2} on page~\pageref{l2}.
\end{document}
In both cases, the \ref refers to section 1, though the \pageref refers to pages 1 and 2 respectively. In both cases, the 'thing being labelled' is the section, and the text that goes in the label, and which appears in the \ref, is the section number.
So if you want to refer to an 'arbitrary place in the text', you have to ask yourself 'what is the text that would be produced by the \ref?'

Redefining sectioning commands in latex, issues with references and labels

I'm trying to change the appearance of one of the native sectioning commands in LaTeX. But after doing so, latex cannot handle references as expected.
The code given later is expected to output a document with the text
1 One
See section 2.
2 Two
See section 1.
But instead I get the following.
1 One
See section .
2 Two
See section .
What can I change in the renewed command, such that the references will work again.
The code for the document is as follows:
\documentclass{article}
\newcounter{seccnt}
\renewcommand{\section}[1]{\vspace{2em}\stepcounter{seccnt} \theseccnt~ {\Large #1}\vspace{0.5em}}
\begin{document}
\section{One}
\label{secOne}
See section \ref{secTwo}.
\section{Two}
\label{secTwo}
See section \ref{secOne}.
\end{document}
I think you need to use \refstepcounter instead of \stepcounter, so that the reference is stored.

how to rename sections in latex

How can i give another name to the main sections of a scientific paper in Latex? So instead of 'References' i wanna write a different title, instead of 'Abstract' another, and so on.
Regards
Redefine any of the following commands:
Abstract: \abstractname
Appendix: \appendixname
Bibliography: \bibname
Chapter: \chaptername
Contents: \contentsname
Index: \indexname
List of Figures: \listfigurename
List of Tables: \listtablename
Part: \partname
References: \refname
So, for example,
\renewcommand\refname{My References}
The list comes from The LaTeX Companion, 2nd edition, page 34.
For references \bibname is defined in the book class, but not in the article class. The latter is using \refname.
thanks! helped me a lot.
Just to help other fellas, it did not work for me before \begin{document}
I did it just before \part as below:
\renewcommand\partname{Capítulo}
\part{\textit{Conjuntura regulatória}}
\chapter{\large MATRIZ ENERGÉTICA BRASILEIRA}
worked as a charm.

Resources