4

I would like to print my references part non-indented. I have found information regarding how to indent bib items, but not regarding my problem. I am trying to have the second line of references non-indented as obeying the margin restrictions of the rest of my document which are provided by \geometry{verbose,tmargin=1.25in,bmargin=1.25in,lmargin=1.4in,rmargin=1.15in} command. 'bibliography' file includes my references. Thanks very much in advance! Here is my MWE:

\documentclass[12pt]{report}
\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=1.25in,bmargin=1.25in,
lmargin=1.4in,rmargin=1.15in}
\usepackage[doublespacing]{setspace}
\usepackage{indentfirst}

\begin{document}
Text goes here. ..\cite{ito92, joannopoulos95}
Here, n describes the increase in P1 by nucleation. The gain
($gP_{L-1}$) and loss ($-P_{L}$) terms are due to subunit addition.

\bibliographystyle{unsrt}
\bibliography{references}

\end{document}

The compiled file is enter image description here

  • Welcome to TeX.SX!. Now your MWE does not show the problem. Also, it should be minimal, so all those packages seem a bit too many. Can you remove them? I suggest using lipsum or blindtext for filler text, and adding some kind of bibliography, instead of a lot of \includes which clearly cannot be of use. – MickG Oct 29 '15 at 17:31
  • Is the latexindent tag appropriate here? – cmhughes Oct 29 '15 at 17:32
  • @cmhughes I'm no expert but it sure seems suitable :). – MickG Oct 29 '15 at 17:43
  • Though learning it is a package and is not called in the MWE I might rethink that… perhaps it could help? @EsmaEryilmaz – MickG Oct 29 '15 at 17:45
  • @cmhughes you wouldn't be the Chris Hughes who wrote latexindent.pl as the manual.pdf says, would you :)? – MickG Oct 29 '15 at 17:48
4

Note: this is VERY hacky. Perhaps there is a smarter way to do this. Anyway:

\documentclass[12pt]{report}
\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=1.25in,bmargin=1.25in,
lmargin=1.4in,rmargin=1.15in}
\usepackage[doublespacing]{setspace}
\usepackage{indentfirst}
\usepackage{enumitem}
\makeatletter
\renewenvironment{thebibliography}[1]
     {\chapter*{\bibname}%
      \setbox2\hbox{\@biblabel{#1}}
      \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
      \begin{enumerate}[itemindent=!,leftmargin=0pt,label={\@biblabel{\@arabic\c@enumiv}\setbox2\hbox{\@biblabel{\@arabic\c@enumiv}}\hspace{\labelwidth}\hspace{-\wd2}},labelwidth=\wd2]
            \usecounter{enumiv}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \end{enumerate}}
\makeatother

\begin{document}
Text goes here. ..\cite{ito92, joannopoulos95}

Here, n describes the increase in P1 by nucleation. The gain ($gP_{L-1}$) and loss ($-P_{L}$) terms are due to subunit addition.

\bibliographystyle{unsrt} \bibliography{references}

\begin{thebibliography}{11}
\bibitem{ito92}
Foo Bar Baz,
\emph{Lorem Ipsum dolor sit amet},
Consectetuer editions,
March 24th, 1993,
Rivendell.
\bibitem{mu}
qef
\bibitem{2424}
oihoiwrgh
\bibitem{qeqefqe}
3t31tsef
\bibitem{214}
qeeqfr
\bibitem{1235689}
12345678900987654321
\bibitem{3215}
asdsad
\bibitem{124124}
14124124
\bibitem{134134}
adgvadagd
\bibitem{foobarbazbellheisenbug}
Schrodinbug Heisenbug Schrodinbug Lorem ipsum dolor sit amet consectetuer adipiscing elit foobar
\end{thebibliography}
\end{document}

I redefined the bibliography environment to use an enumerate environment from enumitem, and fiddling with the parameters I managed to get the desired result. Many pieces of code are copied off the definition of the bibliography environment taken from report. My edits are in the part from \setbox1 to \usecounter. There, I set box 1 to \@biblabel{#1} which is the correct label width as was previously set by the class. \@mkboth is off the class. Then we have the list. THe options itemindent and leftmargin are set as suggested by "Original answer" here, so thank karlkoeller for that. label= is sorf of copied off the class, though the \hspace is what solved the problem in the comment's screenshot, or rather the variant where 1 was a bit to the right of the left margin: basically it places exactly enough space to align the 1 with the second line. labelwidth= takes the width of box 1 at the moment of the list's start (so box 1 is what was set by \setbox1) as its value. So the label width is, in this case, [10]'s width, but when the label would be tighter it is not flushed right but an \hspace is inserted that gets it exactly aligned on the left. Here is the output:

enter image description here

Is that it?


Simplified version still using enumitem

Change the code between \makeatletter and \makeatother with

\makeatletter
\newlength\biblabelwd
\renewenvironment{thebibliography}[1]
 {\chapter*{\bibname}%
  \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
  \settowidth\biblabelwd{\@biblabel{#1} }%
  \begin{enumerate}[
    itemindent=\biblabelwd,
    leftmargin=0pt,
    label={\makebox[\biblabelwd][l]{\@biblabel{\arabic{enumiv}}}},
    labelwidth=0pt,
    labelsep=0pt
  ]
  \usecounter{enumiv}%
  \sloppy
  \clubpenalty4000
  \@clubpenalty \clubpenalty
  \widowpenalty4000%
  \sfcode`\.\@m}
 {\def\@noitemerr
  {\@latex@warning{Empty `thebibliography' environment}}%
  \end{enumerate}}
\makeatother
  • 1
    You shouldn't be using \box1, but \box2. Odd numbered scratch registers should be used only for global assignments. – egreg Oct 29 '15 at 21:11
  • @egreg whoops I got odd and even mixed up, I thought odd = local and even = global :). – MickG Oct 29 '15 at 21:12
  • 1
    I found an easier way to set the parameters; since it's just a variation of your method, I think the best thing is to make an edit. – egreg Oct 29 '15 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.