Remove spacing before \chapter in LaTeX [closed] - latex

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am using the book style to write a research report and would like to know how to remove the top vertical space before a chapter heading. I need this for the 'Abstract' page. I would like it to start nearer to the top than standard chapters.

Here is some sample code using the titlesec package, Stefan's suggestion. The titleformat command leaves everything at default values, but you need to include it (I think) for the titlespacing changes to work. The second titlespacing command sets back to default values, with assumption that you wanted altered spacing only for first chapter:
\documentclass{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
% this alters "before" spacing (the second length argument) to 0
\titlespacing*{\chapter}{0pt}{0pt}{40pt}
\begin{document}
\chapter{One}
% this changes "before" spacing back to its default of 50pt
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
First sentence of chapter.
\chapter{two}
First sentence of chapter.
\chapter{three}
First sentence of chapter.
\end{document}

An easy way is using the titlesec package. The appendix 9.2 of its documentation shows how the standard classes typeset their headings - it's not hard to copy and to modify those commands according to the own requirements.

Having the same issue, i tried out the titlesec solution, which somehow didn't work as expected (too many errors with Texshop 2.47 on OsX).
However, i worked out a simpler solution (at least for my case) with the geometry package. The deal is to call a new page geometry only for the page of interest and then restore the page geometry defined by fncychap.
% in the preamble
\documentclass[11pt,a4paper,twoside,openright]{book}
\usepackage{geometry}
\usepackage[Sonny]{fncychap}
% in the document
\frontmatter
% adapt geometry options to your needs
\newgeometry{textwidth=16cm,textheight=28cm,voffset=-2cm,bottom=0cm}
\chapter*{Abstract}
\markboth{}{}
\addcontentsline{toc}{chapter}{Abstract}
% text
\restoregeometry
% from now on fncychap takes over again
\mainmatter

Related

How can I highlight text in latex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
How can i highlit text in latex.
Thank you.
As is pictured here(in red circle):
If you mean making the text bold by Highlighting you can use \textbf for making the text bold but highlighting has a different general meaning that is implemented by \hl keyword.
\documentclass{report}
\usepackage{color} % for the command \textcolor
\usepackage{soul} % for the command \hl
\begin{document}
\hl{foo}
\hl{\textbf{foo}}
{my garden }
\textbf{black}{foo}
{my good job}
\textbf{\textcolor{red}{\hl{foo}}}
\textcolor{red}{\textbf{\hl{foo}}}
\end{document}
this is the result :
As you can see the word "black" is highlighted the way you desired.
The word "foo" is highlighted in the general meaning of highlighting.
This links look useful:
Insert symbols inside verbatim mode LaTeX
Putting math inside a verbatim environment without altering the formatting
If you just wanted graph.exe I would suggest using \begin{verbatim} graph.exe \end{verbatim} or \verb+graph.exe+ .
However you want to use the <..> expression which can be created with $ \langle ... \rangle $ . The $..$ indicates inline math mode. Those two links discuss getting verbatim text in math environments.
I think tex.stackexchange.com will be more helpful rather than stack overflow.

\begin{figure}[H] works, but \begin{figure}[htbp] doesn't [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to insert png files into my document.
basically, like this, it works (after invoking 'float'),
\begin{figure}[H]
\begin{center}
\includegraphics{myfigure}
\caption{short caption}{VERY LONG FIGURE LEGEND}
\label{fig:myfigure}
\end{center}
\end{figure}
but like that, it doesn't,
\begin{figure}[htbp!]
\begin{center}
\includegraphics{myfigure}
\caption{short caption}{VERY LONG FIGURE LEGEND}
\label{fig:myfigure}
\end{center}
\end{figure}
which is weird to me; obviously I invoke \usepackage{graphicx} as well since without that it wouldn't work in the first place. Any suggestions what the problem could be?
UPDATED: found the solution:
I had defined the \textsuperscript macro as in http://anthony.liekens.net/index.php/LaTeX/SubscriptAndSuperscriptInTextMode
a fix is sketched in Figures occurring after ^ and _ macros (was: LaTeX limitation?), and it seems to work for me
cheers!!
I can't test it here, but I think the combination htbp and ! is not allowed. The ! defines that LaTeX should listen to the given placement specifier and place the figure how you specify it. You say with htbp! to LaTeX something like
Place my image here, at the top, at the bottom or on a special page. And do it all!
You should choose either htbp or h!, t!, b! or p!, I think.
found the solution:
I had defined the \textsuperscript macro as in http://anthony.liekens.net/index.php/LaTeX/SubscriptAndSuperscriptInTextMode
a fix is sketched in Figures occurring after ^ and _ macros (was: LaTeX limitation?) and it seems to work for me

input a figure between title and body in twocolumn latex form [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm using a Latex to write a small paper using CVPR template.
I'd like to put a figure between my title+name and body(which consists with two columns) like many CVPR papers do, but I don't find the way to do that.
I tried,
\begin{figure*}
\begin{center}
\fbox{\rule{0pt}{2in} \rule{.9\linewidth}{0pt}}
\end{center}
\caption{some caption..}
\label{fig:short}
\end{figure*}
but it turned out figure-star only displays it's figure at the top of next page,
and when I just use figure like \begin{figure}[htb], it's only located one of those two columns.
Does anyone know how to put a long figure between my title+name and body context?
Thanks.
You don't mention anything about inserting a date in your title. So, why not use the date to store your image:
\documentclass[twocolumn]{article}
\usepackage{mwe}% http://ctan.org/pkg/mwe
\title{My Title}
\author{A.\ Uthor}
\date{\includegraphics[height=2in]{example-image}}
\begin{document}
\maketitle
\lipsum[1-4]
\end{document}
The mwe package provides the example image (via graphicx) and dummy text (via lipsum).

Best way to draw a bar chart in LaTeX? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I was looking for it here in Stack Overflow as in Google, and I found a lot of packages to draw, but it seems a complex task, so I would like to know which is the most appropriate package to draw bars, and associate data to it. Also I was looking for a code example, but I did not have luck.
Package: bchart
Manual
Example code:
\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{bchart}
\begin{document}
\begin{bchart}[step=2,max=10]
\bcbar{3.4}
\smallskip
\bcbar{5.6}
\medskip
\bcbar{7.2}
\bigskip
\bcbar{9.9}
\end{bchart}
\end{document}
Result:
Package: pgfplots
Manual: Page 81 - 89
Example code:
% Source: https://tex.stackexchange.com/a/8584/5645
\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={a small bar, a medium bar, a large bar},
xtick=data
]
\addplot[ybar,fill=blue] coordinates {
(a small bar, 42)
(a medium bar, 50)
(a large bar, 80)
};
\end{axis}
\end{tikzpicture}
\end{document}
Result:
I plan to add some more examples to my GitHub repository. You might also be interested in tex.stackexchange.com tag:bar-chart.
That sounds like an easy job for the pgfplots package. Section 4.5 from the manual contains a lot of examples to start from, everything is explained from scratch and step-by-step. If you need more pgfplots examples, the section dedicated to plots at TeXample could be of interest. There aren't any bar plots, but it contains some nice (and more elaborate) examples of the functionality.
As for a code example, I could copy-and-paste one from the manual, but that would not add much to this post I believe.
Edit: when using Matlab, it is possible to use matlab2tikz. This way you can export your plots without having to worry about the actual code. Bar charts should be possible, but I haven't used that functionality yet so I don't know about any quirks. The plots I did export using this Matlab script were perfect and you get the consistency and flexibility you want :).
This might be viewed as sacrilege, but it's actually not that terrible to generate the plot using matlab, excel or any other tool, and merely include the PDF/jpg in. pgfplots is a more elegant option, but might not be the quickest.

How should I add an author subtitle under a chapter title? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Had trouble knowing what exactly to Google, so I'll ask here.
I'm typesetting a series of annotations to papers. Each chapter will be on a paper, so I'd like to put the paper authors right under the chapter names (the paper titles).
I can think of a hacky way of doing this, but I figured I'd ask the fine folks over at SO first for something more elegant / contribute to the knowledge base.
You can use the substr package in addition of titlesec (with explicit option) for create a semantic way of putting authors in titles.
Then, you can write your chapter on this way:
\chapter{About random things on Internet, and another
procrastination issues. Alice Marigold}
In this case the title and the author are separated for a ". " (You can use another separator if you use periods in one of your titles). Then you can modify the \chapter format with titlesec. With the explicit option you can access directly to the title content with #1. Then you can separate the title and the author with the commands \BeforeSubString and \BehindSubString of the substr package, respectively. They have two arguments: the separator token (in this case is ". ") and the string (the title. author).
For a simple example:
\titleformat{\chapter}[hang]{}{%
\Huge \thechapter.
}{1cm}{%
\LARGE \scshape \BeforeSubString{. }{#1}\\
{\Large \itshape ---\BehindSubString{. }{#1}---}%
}
The result is similar to this.
You can make very different forms of place titles and authors, including putting it on the left. This is a example I used in a LaTeX demonstration, with the calc package:
\titleformat{\chapter}[hang]{}{%
\Huge \thechapter.
}{1cm}{%
\LARGE \scshape \BeforeSubString{. }{#1}\\
\makebox[\textwidth - (1cm + \widthof{\Huge \thechapter.})][r]{\Large \itshape \BehindSubString{. }{#1}}%
}
About the table of contents, you can ignore it putting the title without the author in the \chapter optional argument, or modify it with titletoc.
And there are infinite possibilities of writing multi-information titles with these two packages...
PD: Sorry, but for some reason I can't put the CTAN links to the packages.
Why not use a package designed for things like conference proceedings, such as this one?
Grubbing around on CTAN a bit brought me to the bits package which appears to do exactly what you want. From the description:
A LaTeX package that provides a programmer's interface for a new idea called a “bit”, which is like an environment but has a title, author, and other attributes usually only associated with the document environment.
Be warned that the package claims to be "unsupported".
There is also combine:
The combine class lets you bundle individual documents into a single document, such as when preparing a conference proceedings. The auxiliary combinet package puts the titles and authors from \maketitle commands into the main document's Table of Contents. The package cooperates with the abstract and titling packages.
and there may be others, but as you say, it is not easy to search for.

Resources