align-like environment in LaTeX for lines of texts - latex

I am looking for a LaTeX environment, that is capable of formatting given paragraph(s) with a slight indentation and increasing line counters within parenthesis, e.g.:
(1) Lorem Ipsum
(2) Dolor Sit
These numbers should continue to increase throughout the document, i.e. there should be no number used twice. It would behave almost like the align environment- including the possibility to \ref to individual lines, except that I do not wish to use it for math but rather for text snippets.
Unfortunately, I am not that LaTeX savvy, so I cannot really define such an environment myself.

Is this what you're looking for?
\documentclass{article}
\usepackage{lipsum} % just for blind text
\usepackage{enumitem}
\newlist{masterlist}{enumerate}{1}
\setlist[masterlist]{label=(\arabic*),resume}
\begin{document}
\lipsum[1]
\begin{masterlist}
\item foo
\item bar
\end{masterlist}
\lipsum[2-3]
\begin{masterlist}
\item baz
\item boo
\end{masterlist}
\end{document}

In fact you want an enumerate list with number in a non default presentation. An easy way for this is the enumerate package:
\documentclass{article}
\usepackage{enumerate}
\begin{document}
\begin{enumerate}[(1)]
\item test1
\item test2
\end{enumerate}
\end{document}

You could use the align environment (or other math-based environments) and typeset your text using \text{...}. Example:
\begin{equation}\label{mylabel}
\text{Numbered like an equation, typeset like text.}
\end{equation}
Beware, though, that this is only suitable for short snippets of text, since you are, after all, inside a math environment, so there's no automatic line wrapping.

Related

Latex Numbered Hanging \paragraph

I am trying to write a document which uses seperate numbers for sections and paragraphs.
I would like each \paragraph to have a hanging indent such that the first word of the second line, aligns with the first word of the first line.
Here is my code:
\documentclass{article}
\usepackage{a4wide}
\usepackage[english]{babel}
\usepackage{titlesec}
% Heading/Subheading counter
\newcounter{subsubsection}[subsubsection]
\newcounter{param} % Paragraph counter
\newcommand{\N}{%
\noindent\refstepcounter{parnum}%
\makebox[\parindent][l]{\arabic{parnum}.}}
\newcommand\YUGE{\fontsize{60}{100}\selectfont}
% Paragraph style
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}}
\makeatletter
\renewcommand\paragraph{\#startsection{paragraph}{5}{\z#}%
{1em} {-1em} {\normalsize\normalfont}}
\def\toclevel#subsubsubsection{4}
\def\toclevel#paragraph{5}
\def\l#subsubsubsection{\#dottedtocline{4}{7em}{4em}}
\def\l#paragraph{\#dottedtocline{5}{10em}{5em}}
\makeatother
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Scope}
\pagestyle{style1}
\paragraph*{\N} The Scope of this document should number each paragraph sequentially:
\begin{itemize}
\item [a.] List item 1,
\item [b.] List item 2, and
\item [...] ...
\item [n.] List item n.
\end{itemize}
\paragraph*{\N} Second paragraph with numbering
\subsection{Intro}
\paragraph*{\N} This is the intro.
\paragraph*{\N} Intro cont.
\subsubsection{related docs}
\paragraph*{\N} Here is a list of the related docs
\begin{itemize}
\item [a.] ...
\end{itemize}
\end{document}
This is a picture of what it looks like currently.
Here is a quick example in word as to how I want the paragraphs to work (disregard the different numbering and font type. I am only concerned with the hanging indent).
I found the answer; You need to use the following packages
\usepackage{titlesec}
\usepackage{etoolbox}
Then you need to set the counter depth for the document to 5 and define a new counter. Which means you will be countering every; chapter, section, subsection, subsubsection, paragraph and subparagraph.
\setcounter{secnumdepth}{5}
\newcounter{para}
\newcommand{\N}{\noindent\refstepcounter{para}\makebox[\parindent][l]{\arabic{para}.}}
Now you can set up the format for each of the sections/subsections/paragraphs/etc
\newlength\titleindent
\setlength\titleindent{1.25cm}
\pretocmd{\paragraph}{\stepcounter{subsubsection}}{}{}
\titleformat{\section}{\normalfont\Large\bfseries}{\llap{\parbox{\titleindent}{\thesection\hfill}}}{0em}{}
\titleformat{\subsection}{\normalfont\large\bfseries}{\llap{\parbox{\titleindent}{\thesubsection\hfill}}}{0em}{}
\titleformat{\subsubsection}{\normalfont\normalsize\bfseries}{\llap{\parbox{\titleindent}{\thesubsubsection}}}{0em}{}
\titleformat{\paragraph}[runin]{\normalfont\normalsize}{\llap{\parbox{\titleindent}{\N\hfill}}}{0em}{}
\titlespacing*{\subsubsection}{0pt}{2ex plus 1ex minus 0.2ex}{1.5ex plus .2ex}
\titlespacing*{\paragraph}{0pt}{2ex plus 1ex minus .2ex}{0ex plus 0ex}
I did not use the subparagraph option to I changed the commands such that the numbering of paragraphs is the same level as subsubsections. This means a subsubsection might be numbered 1.2.1 if you have two paragraphs though the next subsubsection will be 1.2.4 is an issue I have yet to solve.
The below is the original commands:
\pretocmd{\paragraph}{\stepcounter{subsection}}{}{}
\pretocmd{\subparagraph}{\stepcounter{subsubsection}}{}{}
Importantly when writing your code, you need to use the following syntax at the beginning of each paragraph:
\paragraph{} Some text
Here is an example
\begin{document}
\section{title}
\subsection{Intro}
\paragraph{} The Scope of this document should number each paragraph sequentially:
\begin{itemize}
\item [a.] List item 1,
\item [b.] List item 2, and
\item [...] ...
\item [n.] List item n.
\end{itemize}
\paragraph{} Second paragraph with numbering, this is sample text to explain the
hanging indent format, which should align with the second line of this paragraph
with the first line.
\subsection{Intro}
\paragraph{}This is the intro, this is sample text to explain the hanging indent
format, which should align with the second line of this paragraph with the first
line.
\paragraph{} Intro cont, this is sample text to explain the hanging indent format,
which should align with the second line of this paragraph with the first line.
\subsubsection{related docs}
\paragraph{} Here is a list of the related docs
\begin{itemize}
\item [a.] ...
\end{itemize}
\end{document}
This is what it looks like now

Aligning numbered paragraphs

I am trying to cross reference some numbered paragraphs. I am using \numpar but the first one always is off aligned. (\item didn't work)
Here is what I did:
\section{First section}
\subsection*{Subsection1}
\numpar\label{A1} blablabla1
\numpar\label{A2} blablabla2
\numpar\label{A3} blablabla3
\section{Second section}
Statement \ref{A2} = 2 must be true.
which results in:
I need all numbers to be aligned without affecting on unnumbered paragraphs. I am open to other commands instead of \numpar if any. Any advice is appreciated.
Why don't you use enumerate? It is done for that kind of problem.
\documentclass{article}
\begin{document}
\section{First section}
\subsection*{Subsection1}
\begin{enumerate}
\item \label{A1} blablabla1
\item \label{A2} blablabla2
\item \label{A3} blablabla3
\end{enumerate}
\section{Second section}
Statement \ref{A2} = 2 must be true.
\end{document}
If required, you can customize the appearance with the enumitem package.
For instance, to increase the indentation, load the package, and start enumerate with :
\begin{enumerate}[leftmargin=3cm]`
Many options in the enumitem package and it can certainly fit your needs.
Edit:
Note that \item will indent anything that is after it. If you dont want this behavior, close the enumerate before your paragraph. Then you can restart the enumerate, but you must take care of the item numbering (see below).
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\section{First section}
\subsection*{Subsection1}
\begin{enumerate}
\item \label{A1} blablabla1
This paragraph will be indented
\end{enumerate}
But this one will not.
\begin{enumerate}\setcounter{enumi}{1}
% This insures that item numbering will be coherent
% set it to the value of the last item
% If using the enumitem package, there is a simpler way with 'resume'
% \begin{enumerate}[resume]
\item \label{A2} blablabla2
\item \label{A3} blablabla3
\end{enumerate}
And another non indented par
\section{Second section}
Statement \ref{A2} = 2 must be true.
\end{document}

Numbering latex presentation - counting problem

I'm working on a presentation with Latex {beamer}. I have the following problem:
When I use the itemize command on a slide in conjunction with \visible<2->{text} Latex counts a new page for each item. That's why I have something like 17/11 on my presentation.
Does one know how to solve this problem?
With \thispagestyle{empty} I solve the problem only temporarily and not satisfactorily
If I understood correctly, you may not want a new page (slide) for each item in each itemize environment in your presentation, for example if you have to print your slides. In this case, you may switch from
\documentclass{beamer}
to
\documentclass[handout]{beamer}
before compiling again and print your output pdf file (whose page count will now be the same or smaller). The handout option is discussed in section 4.6 of this Beamer User Guide.
Don't show the page number, but use the frame number instead:
\documentclass{beamer}
%\setbeamertemplate{footline}[page number]
\setbeamertemplate{footline}[frame number]
\begin{document}
\begin{frame}
\begin{itemize}
\item text text
\item text \visible<2->{text}
\end{itemize}
\end{frame}
\end{document}

sequence in latex not as expected

I just started learning Latex and I have this code in which I first define a figure which is a photo and then I want to have items in my PDF file.
But the output file isn't so and it first shows the items and then the photo! even though I have [!h] statement too.
\documentclass[12pt]{report}
\begin{document}
\begin{figure}[!h]
\centering
\includegraphics[width= 90mm]{./class.jpg}
\caption{pic1}
\end{figure}
\begin{enumerate}
\item first option with number
\item second option with number
\end{enumerate}
\end{document}
What I do is to use the package float and change !h for H
\documentclass[12pt]{report}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
\includegraphics[width= 90mm]{./class.jpg}
\caption{pic1}
\end{figure}
\begin{enumerate}
\item first option with number
\item second option with number
\end{enumerate}
\end{document}
This forces latex to place the image right in the position you put it.
When I compile your code with \usepackage{graphicx}, and using a generic image, I first get the image, then the item list. Usually LaTeX will force the image onto the next empty page, if the image is too large (the width may fit, but possibly the height is off?). Maybe try playing with \includegraphics[scale=0.8].

columns with itemize

I'm trying to make alignment points in a list environment. The following code gives me an error, but it almost compiles to what I want, just missing the bullet points. I must be misunderstanding something about align and/or tabular and how they work with linebreaks. Guidance appreciated!
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{itemize}
\begin{tabular}{ll}
\item Topic Apple: &Something to say about it \\
\item Topic Watermelons: &Something different
\end{tabular}
\end{itemize}
\end{frame}
\end{document}
How about this?
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{tabular}{p{0.4\textwidth}p{0.5\textwidth}}
\begin{itemize}
\item Topic Apple:
\item Topic Watermelon:
\end{itemize} &
\begin{itemize}
\item[] Something to say about it
\item[] Something to say about it
\end{itemize} \\
\end{tabular}
\end{frame}
\end{document}
Yours will actually work if you change {ll} to {p{width}l} or {p{width}p{width}} but I found that if you don't have itemize in the second column, your text ends up vertically top aligned while the itemized text in the left column is center (or maybe even slightly bottom) aligned vertically so it doesn't look good.
I tried using the array package and m{width} which provides a vertical center alignment but that was still different than whatever itemize is using. I'd say just play with the width argument inside of p{} to get the spacing/width you want. If your right column spills on to another line, you may need a "dummy" item in the right column.
Anyway, based on all the jimmy rigging that might be necessary if things spill onto two lines, I'm assuming my solution is potentially hackish but it looks like it provides what you want for the most part.
the \item[] for the right column is to create the same itemize alignment with no bullet. If you want bullets on the right, just remove the empty square brackets and you'll have them.

Resources