LaTeX: indent from second line - latex

I want to indent from the second line.
I want to write in LaTeX something like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam interdum dictum suscipit magna molestie. Vestibulum nibh dolor, interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper in commodo erat dignissim. Cras et suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus. Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla imperdiet cursus enim condimentum congue.
And I want to produce:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.

Depending on why you want to do this, you might be better off using the built-in TeX support for hanging indentation, which the hanging package sugars. If it's a one-off, use the package, but if it's built in to some other layout, the package might just confuse things. Up to you.
The \hangindent dimension gives the size of the indentation, and the \hangafter number indicates when that indentation should start or stop. If the \hangafter number is positive, then indentation starts after that number of lines; if it's negative, then it starts immediately and stops after (minus) that many lines.
These apply only to the immediately following paragraph. The hanging package handles this by using \everypar. That's an occasionally problematic technique, which is why the package includes a 'word of caution' about it.
\documentclass{article}
\parindent=0pt
\parskip=\medskipamount
\begin{document}
\hangindent=2em
\hangafter=2
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
\hangindent=2em
\hangafter=-2
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.
\end{document}

Negative hanging indentations in LaTeX are most easily handled with the hanging package.
Edit: Fixed the broken link.

Similar to Ricibald's answer but simpler (it wasn't clear to me in his post which length was doing the job). I was using this for a bulleted list to indent each line after the first:
\begin{list}{}%
{\leftmargin=1em \itemindent=-1em}
\item
\item
\end{list}

\hangindent=\parindent
\hangafter=1
\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.

I found this solution. For me it's better because it is valid for all text since this point: I don't need to repeat the command for every paragraph:
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{0.1in}%
\setlength{\listparindent}{-0.1in}%
\setlength{\itemindent}{-0.1in}%
\setlength{\parsep}{\parskip}%
}%
\item[]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.
\end{list}
Now my normal text!

When you create a list the list margin is indented by one indent (\leftmargini) and \itemindent is 0; if you set the \itemindent equal to the negative of the left margin, the hanging indent will line up exactly with the outer scope margin, and you'll get exactly one indent inside the list. It is a quick and simple way to get in and out of a hanging indented list setting only one value: \itemindent.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{list}{}{\setlength\itemindent{-\leftmargin}}
\item \lipsum[1]
\item \lipsum[2]
\end{list}
\end{document}

How about:
\usepackage{changepage}
\newenvironment{indentblock}{\begin{adjustwidth}{\parindent}{}\hspace{-\parindent}}{\end{adjustwidth}}
\begin{document}
\begin{indentblock}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam interdum dictum suscipit magna molestie. Vestibulum nibh dolor, interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper in commodo erat dignissim. Cras et suscipit enim.
\end{indentblock}
\end{document}
Simply change \parindent to a value of your liking, e.g., 4em.

You can modify globally or locally the length named parindent (that has a default value depending on your documentclass and packages and options):
\documentclass{article}
\usepackage{lipsum}
\setlength\parindent{-3em}
\begin{document}
\lipsum[1]
\setlength\parindent{0pt}
\lipsum[2]
\end{document}

Related

pandoc beamer text overflows

using pandoc's beamer SLIDES example, if one slide is too long, the PDF slide overflows.
How can I make the font size automatically adapt to fit the content in the slide ?
% Eating Habits
% John Doe
% March 22, 2005
# In the morning
- Eat eggs
- Drink coffee
# In the evening
- Eat spaghetti
- Drink wine
# Lorem ipsum
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.
- Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna.
Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet.
You could use the beamer shrink frame option which will scale down the content of the whole frame:
% Eating Habits
% John Doe
% March 22, 2005
# In the morning
- Eat eggs
- Drink coffee
# In the evening
- Eat spaghetti
- Drink wine
# Lorem ipsum {.shrink}
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.
- Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna.
Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet.
If you don't mind using a bit of tex code, you could use a tcolorbox to automatically choose a font size with which the text will fit the page:
---
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage{tcolorbox}
- \tcbuselibrary{fitting}
- \usepackage{lipsum}
---
# In the morning
- Eat eggs
- Drink coffee
# In the evening
- Eat spaghetti
- Drink wine
# Lorem ipsum
\begin{tcolorbox}[fit,width=\textwidth,height=.9\textheight,size=minimal,colback=white,colframe=white,fit algorithm=fontsize]
\begin{itemize}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.
\item Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna.
Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet.
\end{itemize}
\end{tcolorbox}

How to add text to each entry in the "list of listings"?

I need to use the package "listings" in a huge XeLaTeX document to modify each entry in the "list of listings". I managed to show the chapter number, the number within chapter, the caption, several dots, and the page number for each entry. However, I have been unable to include the word "CODE" for each entry at the beginning of each line.
I have read several forums regarding this topic, but the answers are confusing and not conclusive. It seems the best way is employing \thelstlisting but I got an error saying it is not defined (btw, I'm kinda new to Latex).
Now a MWE (minimal working example):
\NeedsTeXFormat{LaTeX2e}
\documentclass{report}
\RequirePackage[spanish,english]{babel}
\RequirePackage{inputenc}
\RequirePackage{hyperref}
\RequirePackage[all]{hypcap}
\RequirePackage{caption}
\RequirePackage{listings}
\renewcommand{\lstlistlistingname}{\centerline{My own title for codes}}
\renewcommand{\lstlistingname}{Source code example}
\begin{document}
\chapter{Introduction}
\section{History}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel hendrerit massa, vitae aliquam est. Nullam mauris lacus, scelerisque non risus sed, sagittis rutrum mi. Quisque malesuada sagittis gravida. Duis placerat interdum dui. Etiam eu nibh vel sapien laoreet posuere. Cras vel auctor arcu.
\lstinputlisting[language=Python, numberbychapter=true, frame=single, caption={How to do NNN}]{code.py}
Metus aliquam rutrum gravida. Nullam dapibus accumsan odio ut maximus. Aliquam bibendum felis nisl, eu faucibus ante placerat vitae. Suspendisse turpis est, ultricies a posuere non, pellentesque nec nunc. Sed pharetra quis sem nec tincidunt. Donec ultricies felis id risus faucibus.
%% FOLLOWING LINE DOESN'T GET ANY ERROR, IN FACT IT DOES NOTHING!!
\renewcommand{\thelstlisting}{CODE~\arabic{lstlisting}}
\lstlistoflistings
\end{document}
(file code.py has few lines of Python code)
The first line in the listings is:
1.1 How to do NNN .............. 1
However, the word "CODE" is missing. It should read:
CODE 1.1 How to do NNN .............. 1
The command \renewcommand*{\thelstlisting}{CODE~\arabic{lstlisting}} is not working within the document, and before the document it gets an error that says: thelstlisting is undefined.
What could I do to make the word CODE appear at front of each entry?
Your redefinition of \thelstlisting comes too late. You would need to place it before the listsings. However there it would mess up the captions and other things like cross references. Instead I suggest to modify the format of the entries in the list of listings:
\NeedsTeXFormat{LaTeX2e}
\documentclass{report}
\RequirePackage[spanish,english]{babel}
\RequirePackage{inputenc}
\RequirePackage{hyperref}
\RequirePackage[all]{hypcap}
\RequirePackage{caption}
\RequirePackage{listings}
\renewcommand{\lstlistlistingname}{\centerline{My own title for codes}}
\renewcommand{\lstlistingname}{Source code example}
\begin{filecontents*}{code.py}
zzz
\end{filecontents*}
\makeatletter
\def\l#lstlisting#1#2{\#dottedtocline{1}{3.4em}{2.3em}{Code #1}{#2}}
\makeatother
\begin{document}
\chapter{Introduction}
\section{History}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel hendrerit massa, vitae aliquam est. Nullam mauris lacus, scelerisque non risus sed, sagittis rutrum mi. Quisque malesuada sagittis gravida. Duis placerat interdum dui. Etiam eu nibh vel sapien laoreet posuere. Cras vel auctor arcu.
\lstinputlisting[language=Python, numberbychapter=true, frame=single, caption={How to do NNN}]{code.py}
Metus aliquam rutrum gravida. Nullam dapibus accumsan odio ut maximus. Aliquam bibendum felis nisl, eu faucibus ante placerat vitae. Suspendisse turpis est, ultricies a posuere non, pellentesque nec nunc. Sed pharetra quis sem nec tincidunt. Donec ultricies felis id risus faucibus.
%% FOLLOWING LINE DOESN'T GET ANY ERROR, IN FACT IT DOES NOTHING!!
%\renewcommand{\thelstlisting}{CODE~\arabic{lstlisting}}
\lstlistoflistings
\end{document}

LaTeX hanging paragraphs

I'd like to set up my paragraphs to hang only on the second line. The hanging environment will hang after a particular line, but not on a specific line.
To piggyback off of another question LaTeX: indent from second line, I want it to produce something like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.
It would also be nice if this could be a set document wide instead of just an environment, but not necessary.
EDIT: Here is my best example of what each paragraph looks like.
\documentclass{article}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam interdum dictum suscipit magna molestie. Vestibulum nibh dolor, interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper in commodo erat dignissim. Cras et suscipit enim.\\
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus. Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla imperdiet cursus enim condimentum congue.\\
\end{document}
You can update \everypar to insert a specific \parshape. This should re-organize the flow to match your requirement:
\documentclass{article}
\usepackage{etoolbox,lipsum}
\newlength{\saveparindent}\setlength{\saveparindent}{\parindent}
\setlength{\parindent}{0pt}
\newcommand{\updateeverypar}{%
\parshape 3
0pt \linewidth
\saveparindent \dimexpr\linewidth-\saveparindent\relax
0pt \linewidth}
\makeatletter
\patchcmd{\#xsect}{\ignorespaces}{\ignorespaces\everypar{\updateeverypar}}{}{}
\makeatother
\AtBeginDocument{\everypar{\updateeverypar}}
\begin{document}
\lipsum[1]
\section{Introduction}
\lipsum[2-3]
\section{Conclusion}
\lipsum[4-5]
\end{document}
Note though that \everypar may be updated unexpectedly within standard document elements. See, for example, the spacing above 1 Introduction compared to that of 2 Conclusion. Depending on your application or usage, this might be a problem or not, and may require adjustments.

Remove outer tags but keep inside ones

I'm trying to remove outer p tags if there is another tag inside, the rest of the p tags should be kept. (The last line in the code block below).
<p><img id="__mcenew" src="/media/1902/agf.jpg" alt="" rel="11861" /></p>
<p><h1>Nyt design formidler oplevelserne</h1></p>
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In a erat et quam luctus tincidunt. Mauris convallis mattis sapien, eu laoreet lectus tempus vitae. Duis bibendum feugiat neque, eget porta purus egestas at. Mauris a libero et risus pretium efficitur ut nec diam. In rutrum maximus condimentum. Donec id est turpis. Sed nulla magna, dignissim at tellus sed, pretium pharetra ante. Suspendisse dolor est, gravida sed ultricies non, tempus sed elit.</span></p>
<p><h1>Nyt design formidler oplevelserne</h1></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In a erat et quam luctus tincidunt. Mauris convallis mattis sapien, eu laoreet lectus tempus vitae. Duis bibendum feugiat neque, eget porta purus egestas at. Mauris a libero et risus pretium efficitur ut nec diam. In rutrum maximus condimentum. Donec id est turpis. Sed nulla magna, dignissim at tellus sed, pretium pharetra ante. Suspendisse dolor est, gravida sed ultricies non, tempus sed elit.</p>
This is how I want it to look:
<img id="__mcenew" src="/media/1902/agf.jpg" alt="" rel="11861" />
<h1>Nyt design formidler oplevelserne</h1>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In a erat et quam luctus tincidunt. Mauris convallis mattis sapien, eu laoreet lectus tempus vitae. Duis bibendum feugiat neque, eget porta purus egestas at. Mauris a libero et risus pretium efficitur ut nec diam. In rutrum maximus condimentum. Donec id est turpis. Sed nulla magna, dignissim at tellus sed, pretium pharetra ante. Suspendisse dolor est, gravida sed ultricies non, tempus sed elit.</span>
<h1>Nyt design formidler oplevelserne</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In a erat et quam luctus tincidunt. Mauris convallis mattis sapien, eu laoreet lectus tempus vitae. Duis bibendum feugiat neque, eget porta purus egestas at. Mauris a libero et risus pretium efficitur ut nec diam. In rutrum maximus condimentum. Donec id est turpis. Sed nulla magna, dignissim at tellus sed, pretium pharetra ante. Suspendisse dolor est, gravida sed ultricies non, tempus sed elit.</p>
Any help is appreciated, I've tried a few things out in JS/JQuery and Razor/C#, but i'm stuck on this.
Fixed it using jQuery unwrap() method.
for images:
$("#maincontent img").unwrap();
for span:
$("#maincontent span").unwrap();
Also changes span tags to p tags using (not in the question, but part of the solution to the problem I had):
$("#maincontent span").each(function () {
var $this = $(this);
var $html = $this.html();
$this.replaceWith("<p>" + $html + "</p>");
});
Try to use this
("body p")
.html()
.appendTo("body")
.end()
.remove();
This should remove all <p> in the body of your document

Primefaces Scrollable Layout

Is it possible to make a Primefaces Layout Scrollable? I dont want to make my layoutUnits scrollable as I dont really want multiple scrollable elements on the pages. I would prefer for the page & content panels to resize according to the content, so the user can view the data in a linear fashion. I am currently using a full page primefaces layout:
<p:layout fullPage="true">
If this isnt possible then what is my best alternatives as I quite like the primefaces components but could live without its layout features.
Cheers
You can create a layoutUnit for center, then provide a style class in it, where in your css you can provide scrollable along to x and y position.
<p:layoutUnit position="center">
<div id="myScreen" class="right col scroll-x scroll-y">
<ui:insert name="content">My Screen Content Goes Here</ui:insert>
</div>
</p:layoutUnit>
And in cc file --
.col {
top: 0; bottom: 0;
}
.scroll-x {
overflow-x: auto;
}
.scroll-y {
overflow-y: auto;
}
Hope this would help.
as far as i can tell it cannot be done! I dumped the primefaces layout and went with a generic web layout...
Just put everything in a <p:scrollPanel> component inside the <p:layoutunit>, that will work (now that it's 2015 and we are on Primefaces v5.1.x!). Make sure you add absolute positioning and height to stretch the <p:scrollPanel> to the innards of the <p:layoutunit> - see below.
http://www.primefaces.org/showcase/ui/panel/scrollPanel.xhtml
<p:scrollPanel mode="native" style="position: absolute; height: 100%;">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean blandit tortor a ipsum vehicula, in semper sapien auctor. Nulla tempor eget est non consequat. Nulla sit amet lorem justo. Cras non tellus eros. Sed ultricies orci ut quam interdum fringilla. Nam vitae massa ac mi elementum mattis vel vitae sem. Ut eros ipsum, scelerisque a erat a, eleifend luctus nibh. Interdum et malesuada fames ac ante ipsum primis in faucibus.
</p>
<p>
Vivamus ac ullamcorper magna. Aenean felis ante, elementum sit amet urna at, eleifend aliquet velit. Morbi a convallis magna. In nec leo vel dolor hendrerit pharetra. Cras in iaculis enim. Aenean porta sapien dignissim turpis dapibus, eu dictum velit elementum. Aliquam sollicitudin gravida luctus.
</p>
<p>
Ut vel nulla sit amet erat laoreet eleifend nec sed lacus. Quisque placerat diam vitae justo eleifend, rutrum mollis mauris fringilla. Curabitur turpis odio, euismod id lorem a, ultricies suscipit ligula. Pellentesque ut erat a leo rhoncus porta ac sed velit. Nunc at erat ligula. Fusce vehicula posuere interdum. Curabitur tempus, tortor at sollicitudin dapibus, erat ante varius nisl, id dictum erat ipsum porttitor ipsum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla id varius enim, sed rutrum orci.
</p>
<p>
Sed tincidunt urna quis metus lacinia commodo. Praesent convallis eros vel quam scelerisque bibendum. Mauris eget dignissim libero. Pellentesque sagittis sem quis ipsum viverra, sed consequat mi consectetur. Donec facilisis dapibus ultrices. Donec luctus auctor lacus, at congue nisi aliquet eu. Praesent in justo at risus faucibus ultricies. Fusce et libero lectus. Donec elementum pharetra sapien, at placerat purus sodales et. Vivamus iaculis lacus sed placerat rhoncus. Mauris iaculis sit amet nunc at placerat. Donec consequat euismod lacinia. Etiam nec quam vehicula, cursus massa in, ullamcorper erat.
</p>
<p>
Praesent volutpat scelerisque vestibulum. In eu massa non neque rutrum commodo. Nunc vel enim nisi. Aenean leo ipsum, molestie vel justo nec, pharetra luctus dui. Nunc rhoncus turpis id lorem luctus consequat. Nulla condimentum adipiscing turpis consequat semper. Etiam ullamcorper velit nec hendrerit malesuada. Praesent venenatis leo sit amet arcu commodo, sit amet porta tellus suscipit. Quisque mi tortor, vestibulum in arcu non, pretium auctor libero. In commodo luctus placerat.
</p>
</p:scrollPanel>
I don't believe that layouts are right for what you want to do here. This is good for enabling templating on a single page and the such. You might be able to however put an iframe within a layoutUnit to emulate the same effect though I have never tried this personally and couldn't tell you if it will work or not.

Resources